📄 state.java
字号:
/*
* Copyright 2006 Borys Burnayev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.rdacorp.petstore.domain;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Borys Burnayev
*/
@Entity
@Table(name = "us_state_type")
public class State {
private Integer stateId;
private String code;
private String description;
public State() {
}
public State(String code, String description) {
this.code = code;
this.description = description;
}
@Id
@Column(name = "us_state_id")
public Integer getStateId() {
return this.stateId;
}
public void setStateId(Integer stateId) {
this.stateId = stateId;
}
@Column(name = "code")
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
@Column(name = "description")
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String toString() {
String id = stateId != null ? stateId.toString() : "<no ID>";
return "State " + id + ":\nCode: " + code + "\nDescription: " + description + "\n";
}
public boolean equals(Object object) {
if (!(object instanceof State))
return false;
State state = (State) object;
return code.equals(state.getCode());
}
public int hashCode() {
return code.hashCode();
}
public static State findByID(Collection<State> states, Integer stateID) {
if (states != null) {
for (State state : states) {
Integer id = state.getStateId();
if (id.equals(stateID)) {
return state;
}
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -