CPD Results
The following document contains the results of PMD's CPD 5.1.2.
Duplications
File | Line |
---|
net/sf/uadetector/internal/data/domain/BrowserPattern.java | 74 |
net/sf/uadetector/internal/data/domain/DevicePattern.java | 74 |
return new BrowserPattern(id, pattern, position);
}
/**
* Sets the identification number of a browser pattern entry.
*
* @param id
* identification number
* @return this {@code Builder}, for chaining
* @throws net.sf.qualitycheck.exception.IllegalNegativeArgumentException
* if the given integer is smaller than {@code 0}
*/
@Nonnull
public Builder setId(@Nonnegative final int id) {
Check.notNegative(id, "id");
this.id = id;
return this;
}
/**
* Sets the identification number (ID) of a browser pattern. The given {@code String} is parsed as a decimal
* number.
*
* @param id
* ID of a browser pattern as string
* @return this {@code Builder}, for chaining
* @throws net.sf.qualitycheck.exception.IllegalNullArgumentException
* if the given argument is {@code null}
* @throws NumberFormatException
* if the given string is not parsable as integer
* @throws net.sf.qualitycheck.exception.IllegalNegativeArgumentException
* if the parsed integer is smaller than {@code 0}
*/
@Nonnull
public Builder setId(@Nonnull final String id) {
Check.notEmpty(id, "id");
this.setId(Integer.parseInt(id.trim()));
return this;
}
/**
* Sets a regular expression for a browser pattern.
*
* @param pattern
* compiled representation of a regular expression
* @return this {@code Builder}, for chaining
*/
@Nonnull
public Builder setPattern(@Nonnull final Pattern pattern) {
Check.notNull(pattern, "pattern");
this.pattern = pattern;
return this;
}
/**
* Converts a PERL regular expression in a Java regular expression and sets it in the {@code Builder}.
*
* @param regex
* PERL style regular expression to be converted
* @return this {@code Builder}, for chaining
*/
@Nonnull
public Builder setPerlRegularExpression(@Nonnull final String regex) {
Check.notEmpty(regex, "regex");
setPattern(RegularExpressionConverter.convertPerlRegexToPattern(regex));
return this;
}
/**
* Sets the position of a browser pattern in a set of patterns.
*
* @param position
* position of a browser pattern
* @return this {@code Builder}, for chaining
* @throws net.sf.qualitycheck.exception.IllegalNegativeArgumentException
* if the given integer is smaller than {@code 0}
*/
@Nonnull
public Builder setPosition(@Nonnegative final int position) {
Check.notNegative(position, "position");
this.position = position;
return this;
}
/**
* Sets the position of a browser pattern in a set of patterns. The given {@code String} is parsed as a decimal
* number.
*
* @param position
* position of a browser pattern as string
* @return this {@code Builder}, for chaining
* @throws net.sf.qualitycheck.exception.IllegalNullArgumentException
* if the given argument is {@code null}
* @throws NumberFormatException
* if the given string is not parsable as integer
* @throws net.sf.qualitycheck.exception.IllegalNegativeArgumentException
* if the parsed integer is smaller than {@code 0}
*/
@Nonnull
public Builder setPosition(@Nonnull final String position) {
Check.notEmpty(position, "position");
this.setPosition(Integer.parseInt(position.trim()));
return this;
}
}
private static final long serialVersionUID = 2845531314485836348L;
/**
* Compares to integers.
*
* @param a
* first integer
* @param b
* second integer
* @return {@code -1} if {@code a} is less, {@code 0} if equal, or {@code 1} if greater than {@code b}
*/
private static int compareInt(final int a, final int b) {
int result = 0;
if (a > b) {
result = 1;
} else if (a < b) {
result = -1;
}
return result;
}
/**
* Identification number (ID) of a browser pattern
*/
@Nonnegative
private final int id;
/**
* A compiled representation of a regular expression to detect a browser
*/
@Nonnull
private final Pattern pattern;
/**
* Position of a {@code BrowserPattern} (only relevant if there are multiple patterns for a browser in a
* {@code SortedSet})
*/
@Nonnegative
private final int position;
public BrowserPattern(@Nonnegative final int id, @Nonnull final Pattern pattern, @Nonnegative final int position) { |
File | Line |
---|
net/sf/uadetector/internal/data/domain/BrowserPattern.java | 277 |
net/sf/uadetector/internal/data/domain/DevicePattern.java | 277 |
net/sf/uadetector/internal/data/domain/OperatingSystemPattern.java | 252 |
final BrowserPattern other = (BrowserPattern) obj;
if (id != other.id) {
return false;
}
if (position != other.position) {
return false;
}
if (!pattern.pattern().equals(other.pattern.pattern())) {
return false;
}
if (pattern.flags() != other.pattern.flags()) {
return false;
}
return true;
}
/**
* Gets the identification number (ID) of a browser pattern.
*
* @return identification number (ID) of a browser pattern
*/
@Override
public int getId() {
return id;
}
@Override
public Pattern getPattern() {
return pattern;
}
@Override
public int getPosition() {
return position;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
result = prime * result + position;
result = prime * result + pattern.pattern().hashCode();
result = prime * result + pattern.flags();
return result;
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("BrowserPattern [id="); |
File | Line |
---|
net/sf/uadetector/internal/data/domain/BrowserPattern.java | 249 |
net/sf/uadetector/internal/data/domain/DevicePattern.java | 249 |
public int compareTo(final BrowserPattern other) {
int result = other == null ? -1 : 0;
if (result == 0) {
result = compareInt(getPosition(), other.getPosition());
if (result == 0) {
result = compareInt(getId(), other.getId());
}
if (result == 0) {
result = getPattern().pattern().compareTo(other.getPattern().pattern());
}
if (result == 0) {
result = compareInt(getPattern().flags(), other.getPattern().flags());
}
}
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BrowserPattern other = (BrowserPattern) obj; |
File | Line |
---|
net/sf/uadetector/internal/data/domain/Browser.java | 202 |
net/sf/uadetector/internal/data/domain/Device.java | 115 |
}
@Nonnull
public Builder setIcon(@Nonnull final String icon) {
this.icon = Check.notNull(icon, "icon");
return this;
}
@Nonnull
public Builder setId(@Nonnegative final int id) {
this.id = Check.notNegative(id, "id");
return this;
}
@Nonnull
public Builder setId(@Nonnull final String id) {
setId(Integer.parseInt(Check.notEmpty(id, "id")));
return this;
}
@Nonnull
public Builder setInfoUrl(@Nonnull final String infoUrl) {
this.infoUrl = Check.notNull(infoUrl, "infoUrl");
return this;
}
@Nonnull
public Builder setOperatingSystem(@Nonnull final OperatingSystem operatingSystem) { |
File | Line |
---|
net/sf/uadetector/UserAgent.java | 73 |
net/sf/uadetector/UserAgent.java | 347 |
@Override
public DeviceCategory getDeviceCategory() {
return deviceCategory;
}
@Override
public UserAgentFamily getFamily() {
return family;
}
@Override
public String getIcon() {
return icon;
}
@Override
public String getName() {
return name;
}
@Override
public OperatingSystem getOperatingSystem() {
return operatingSystem;
}
@Override
public String getProducer() {
return producer;
}
@Override
public String getProducerUrl() {
return producerUrl;
}
@Override
public UserAgentType getType() {
return type;
}
@Override
public String getTypeName() {
return typeName;
}
@Override
public String getUrl() {
return url;
} |