Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
added default constructors
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Kreuzer <kai@openhab.org>
  • Loading branch information
kaikreuzer committed Jul 28, 2016
1 parent ea370b1 commit d6192fa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class HSBType extends PercentType implements ComplexType, State, Command
protected BigDecimal hue;
protected BigDecimal saturation;

public HSBType() {
this("0,0,0");
}

public HSBType(DecimalType h, PercentType s, PercentType b) {
this.hue = h.toBigDecimal();
this.saturation = s.toBigDecimal();
Expand Down Expand Up @@ -171,12 +175,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (!(obj instanceof HSBType))
}
if (!(obj instanceof HSBType)) {
return false;
}
HSBType other = (HSBType) obj;
if ((getHue() != null && other.getHue() == null) || (getHue() == null && other.getHue() != null)
|| (getSaturation() != null && other.getSaturation() == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PercentType extends DecimalType {
final static public PercentType HUNDRED = new PercentType(100);

public PercentType() {
super();
this(0);
}

public PercentType(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Formatter;
import java.util.List;

Expand All @@ -31,6 +32,10 @@ public class StringListType implements Command, State {
static final public String ESCAPED_DELIMITER = "\\" + DELIMITER;
static final public String REGEX_SPLITTER = "(?<!\\\\)" + DELIMITER;

public StringListType() {
typeDetails = Collections.emptyList();
}

public StringListType(StringType... rows) {
typeDetails = new ArrayList<String>(rows.length);
for (StringType row : rows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

public class StringType implements PrimitiveType, State, Command {

public final static StringType EMPTY = new StringType("");
public final static StringType EMPTY = new StringType();

private final String value;

public StringType() {
this("");
}

public StringType(String value) {
this.value = value;
}
Expand All @@ -42,15 +46,18 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
}
if (obj instanceof String) {
return obj.equals(value);
}
if (getClass() != obj.getClass())
if (getClass() != obj.getClass()) {
return false;
}
StringType other = (StringType) obj;
if (!value.equals(other.value)) {
return false;
Expand Down

0 comments on commit d6192fa

Please sign in to comment.