Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created November 17, 2015 10:45
Show Gist options
  • Select an option

  • Save javaeeeee/7e6e70dfcebb6e10942e to your computer and use it in GitHub Desktop.

Select an option

Save javaeeeee/7e6e70dfcebb6e10942e to your computer and use it in GitHub Desktop.
User class
/*
* The MIT License
*
* Copyright 2015 Dmitry Noranovich.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.udemy.dropbookmarks.core;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* A class to store user's data.
*
* @author Dmitry Noranovich
*/
public class User {
private long id;
private String username;
private String password;
private List<Bookmark> bookmarks = new ArrayList<>();
public User() {
}
public User(String username, String password) {
this.username = username;
this.password = password;
}
//Auto-generated by an IDE methods:
//equals, hashCode, getters and setters for all fields.
@Override
public int hashCode() {
int hash = 5;
hash = 59 * hash + (int) (this.id ^ (this.id >>> 32));
hash = 59 * hash + Objects.hashCode(this.username);
hash = 59 * hash + Objects.hashCode(this.password);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final User other = (User) obj;
if (this.id != other.id) {
return false;
}
if (!Objects.equals(this.username, other.username)) {
return false;
}
if (!Objects.equals(this.password, other.password)) {
return false;
}
return true;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public List<Bookmark> getBookmarks() {
return bookmarks;
}
public void setBookmarks(List<Bookmark> bookmarks) {
this.bookmarks = bookmarks;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment