summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits/utils/NameSymbol.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/sevenUnits/utils/NameSymbol.java')
-rw-r--r--src/main/java/sevenUnits/utils/NameSymbol.java44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/main/java/sevenUnits/utils/NameSymbol.java b/src/main/java/sevenUnits/utils/NameSymbol.java
index 9388f63..49c44fa 100644
--- a/src/main/java/sevenUnits/utils/NameSymbol.java
+++ b/src/main/java/sevenUnits/utils/NameSymbol.java
@@ -33,7 +33,7 @@ import java.util.Set;
public final class NameSymbol {
public static final NameSymbol EMPTY = new NameSymbol(Optional.empty(),
Optional.empty(), new HashSet<>());
-
+
/**
* Creates a {@code NameSymbol}, ensuring that if primaryName is null and
* otherNames is not empty, one name is moved from otherNames to primaryName
@@ -43,7 +43,7 @@ public final class NameSymbol {
private static final NameSymbol create(final String name,
final String symbol, final Set<String> otherNames) {
final Optional<String> primaryName;
-
+
if (name == null && !otherNames.isEmpty()) {
// get primary name and remove it from savedNames
final Iterator<String> it = otherNames.iterator();
@@ -53,11 +53,11 @@ public final class NameSymbol {
} else {
primaryName = Optional.ofNullable(name);
}
-
+
return new NameSymbol(primaryName, Optional.ofNullable(symbol),
otherNames);
}
-
+
/**
* Gets a {@code NameSymbol} with a primary name, a symbol and no other
* names.
@@ -72,7 +72,7 @@ public final class NameSymbol {
return new NameSymbol(Optional.of(name), Optional.of(symbol),
new HashSet<>());
}
-
+
/**
* Gets a {@code NameSymbol} with a primary name, a symbol and additional
* names.
@@ -90,7 +90,7 @@ public final class NameSymbol {
new HashSet<>(Objects.requireNonNull(otherNames,
"otherNames must not be null.")));
}
-
+
/**
* h * Gets a {@code NameSymbol} with a primary name, a symbol and additional
* names.
@@ -108,7 +108,7 @@ public final class NameSymbol {
new HashSet<>(Arrays.asList(Objects.requireNonNull(otherNames,
"otherNames must not be null."))));
}
-
+
/**
* Gets a {@code NameSymbol} with a primary name, no symbol, and no other
* names.
@@ -122,7 +122,7 @@ public final class NameSymbol {
return new NameSymbol(Optional.of(name), Optional.empty(),
new HashSet<>());
}
-
+
/**
* Gets a {@code NameSymbol} with a primary name, a symbol and additional
* names.
@@ -145,7 +145,7 @@ public final class NameSymbol {
return NameSymbol.create(name, symbol,
otherNames == null ? new HashSet<>() : new HashSet<>(otherNames));
}
-
+
/**
* h * Gets a {@code NameSymbol} with a primary name, a symbol and additional
* names.
@@ -168,7 +168,7 @@ public final class NameSymbol {
return create(name, symbol, otherNames == null ? new HashSet<>()
: new HashSet<>(Arrays.asList(otherNames)));
}
-
+
/**
* Gets a {@code NameSymbol} with a symbol and no names.
*
@@ -181,12 +181,12 @@ public final class NameSymbol {
return new NameSymbol(Optional.empty(), Optional.of(symbol),
new HashSet<>());
}
-
+
private final Optional<String> primaryName;
private final Optional<String> symbol;
-
+
private final Set<String> otherNames;
-
+
/**
* Creates the {@code NameSymbol}.
*
@@ -202,12 +202,12 @@ public final class NameSymbol {
this.symbol = symbol;
otherNames.remove(null);
this.otherNames = Collections.unmodifiableSet(otherNames);
-
+
if (this.primaryName.isEmpty()) {
assert this.otherNames.isEmpty();
}
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -232,7 +232,7 @@ public final class NameSymbol {
return false;
return true;
}
-
+
/**
* @return otherNames
* @since 2019-10-21
@@ -240,7 +240,7 @@ public final class NameSymbol {
public final Set<String> getOtherNames() {
return this.otherNames;
}
-
+
/**
* @return primaryName
* @since 2019-10-21
@@ -248,7 +248,7 @@ public final class NameSymbol {
public final Optional<String> getPrimaryName() {
return this.primaryName;
}
-
+
/**
* @return symbol
* @since 2019-10-21
@@ -256,7 +256,7 @@ public final class NameSymbol {
public final Optional<String> getSymbol() {
return this.symbol;
}
-
+
@Override
public int hashCode() {
final int prime = 31;
@@ -269,7 +269,7 @@ public final class NameSymbol {
+ (this.symbol == null ? 0 : this.symbol.hashCode());
return result;
}
-
+
/**
* @return true iff this {@code NameSymbol} contains no names or symbols.
*/
@@ -277,7 +277,7 @@ public final class NameSymbol {
// if primaryName is empty, otherNames must also be empty
return this.primaryName.isEmpty() && this.symbol.isEmpty();
}
-
+
@Override
public String toString() {
if (this.isEmpty())
@@ -288,7 +288,7 @@ public final class NameSymbol {
else
return this.primaryName.orElseGet(this.symbol::orElseThrow);
}
-
+
/**
* Creates and returns a copy of this {@code NameSymbol} with the provided
* extra name. If this {@code NameSymbol} has a primary name, the provided