
net.cassite.daf4j.util.Location Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of daf4j-api Show documentation
Show all versions of daf4j-api Show documentation
A library provides facade api for data accessing.
The newest version!
package net.cassite.daf4j.util;
import java.util.ArrayList;
import java.util.List;
/**
* 位置信息
*/
public class Location {
private final List location;
/**
* 通过通过List<String>定义一个位置
* 位置根据list中元素的先后确定
* 例如,[A,B,C]则定义了一个A(B(C))的位置
* 传入的List不会直接使用,而是先进行复制
*
* @param location List定义的位置,若为null则将初始化为空表
*/
public Location(List location) {
if (location == null) this.location = new ArrayList();
else this.location = new ArrayList(location);
}
/**
* 获取位置定义List
*
* @return 位置定义List.该List不会直接返回, 而是先进行拷贝
*/
public List getLocation() {
return new ArrayList(location);
}
@Override
public boolean equals(Object o) {
if (o instanceof Location) {
if (this.location.size() == ((Location) o).location.size()) {
for (int i = 0; i < location.size(); ++i) {
if (!this.location.get(i).equals(((Location) o).location.get(i))) {
return false;
}
}
return true;
} else {
return false;
}
} else {
return false;
}
}
@Override
public int hashCode() {
int r = 0;
for (String s : location) {
r += s.hashCode();
}
return r;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for (String loc : location) {
if (isFirst) {
isFirst = false;
} else {
sb.append(".");
}
sb.append(loc);
}
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy