summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/asn1/datatypes
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/uic/barcode/asn1/datatypes')
-rw-r--r--src/main/java/org/uic/barcode/asn1/datatypes/Alphabet.java1
-rw-r--r--src/main/java/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java32
-rw-r--r--src/main/java/org/uic/barcode/asn1/datatypes/Bitstring.java2
-rw-r--r--src/main/java/org/uic/barcode/asn1/datatypes/Optional.java96
4 files changed, 1 insertions, 130 deletions
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Alphabet.java b/src/main/java/org/uic/barcode/asn1/datatypes/Alphabet.java
index 2b153ae..0202e16 100644
--- a/src/main/java/org/uic/barcode/asn1/datatypes/Alphabet.java
+++ b/src/main/java/org/uic/barcode/asn1/datatypes/Alphabet.java
@@ -3,7 +3,6 @@ package org.uic.barcode.asn1.datatypes;
/**
* Alphabet class for Restricted Strings.
*
- * Use {@link AlphabetBuilder} for convenient construction of restriction alphabets.
*/
public abstract class Alphabet {
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java b/src/main/java/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java
deleted file mode 100644
index b768897..0000000
--- a/src/main/java/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.uic.barcode.asn1.datatypes;
-
-
-public class AlphabetBuilder {
-
- private final StringBuilder sb = new StringBuilder();
-
- public AlphabetBuilder() {}
-
- public String chars() {
- return sb.toString();
- }
-
- public AlphabetBuilder withRange(char from, char to) {
- for (char c = from; c <= to; c++) {
- sb.append(c);
- }
- return this;
- }
-
- public AlphabetBuilder withChars(String str) {
- sb.append(str);
- return this;
- }
-
- public AlphabetBuilder withChars(Character... chars) {
- for (char c : chars) {
- sb.append(c);
- }
- return this;
- }
-}
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Bitstring.java b/src/main/java/org/uic/barcode/asn1/datatypes/Bitstring.java
index 1543f64..4771931 100644
--- a/src/main/java/org/uic/barcode/asn1/datatypes/Bitstring.java
+++ b/src/main/java/org/uic/barcode/asn1/datatypes/Bitstring.java
@@ -9,7 +9,7 @@ import java.lang.annotation.Target;
* In UPER, a SEQUENCE OF Booleans would look exactly as bitstring, so this annotation can be
* omitted for {@code List<Boolean>}.
*/
-@Target({ElementType.TYPE})
+@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Bitstring {
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Optional.java b/src/main/java/org/uic/barcode/asn1/datatypes/Optional.java
deleted file mode 100644
index 757ba29..0000000
--- a/src/main/java/org/uic/barcode/asn1/datatypes/Optional.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.uic.barcode.asn1.datatypes;
-
-import java.util.NoSuchElementException;
-import java.util.Objects;
-
-/** Represents optional values.
- *
- * Should be replaced by java.util.Optional from Java 8, when project moves to Java 8.
- *
- * @param <T> type of contained elements */
-public class Optional<T> {
-
- private final T element;
- private final boolean isPresent;
-
- private Optional(T element, boolean isPresent) {
- this.element = element;
- this.isPresent = isPresent;
- }
-
- /** @return true if the Option contains a value */
- public boolean isPresent() {
- return isPresent;
- }
-
- /** @return the element if the option is not empty
- * @throws java.util.NoSuchElementException if the option is empty */
- public T get() {
- if (isPresent) {
- return element;
- } else {
- throw new NoSuchElementException("None.get");
- }
- }
-
- /** @return the value, if present, otherwise return {@code other}
- * @param other the value to be returned if there is no value present */
- public T orElse(T other) {
- return isPresent() ? get() : other;
- }
-
- /**
- * Indicates whether some other object is "equal to" this Optional. The
- * other object is considered equal if:
- * <ul>
- * <li>it is also an {@code Optional} and;
- * <li>both instances have no value present or;
- * <li>the present values are "equal to" each other via {@code equals()}.
- * </ul>
- *
- * @param obj an object to be tested for equality
- * @return {code true} if the other object is "equal to" this object
- * otherwise {@code false}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof Optional)) {
- return false;
- }
-
- Optional<?> other = (Optional<?>) obj;
- return Objects.equals(element, other.element);
- }
-
- /**
- * Returns the hash code value of the present value, if any, or 0 (zero) if
- * no value is present.
- *
- * @return hash code value of the present value or 0 if no value is present
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(element);
- }
-
- /** Returns an Option containing the value.
- *
- * @param <A> the type of the value
- * @param element contained value
- * @return a new Option that contains the value */
- public static <A> Optional<A> of(final A element) {
- return new Optional<A>(element, true);
- }
-
- /** Returns an empty option.
- *
- * @param <A>
- * @return an empty Option */
- public static <A> Optional<A> empty() {
- return new Optional<A>(null, false);
- }
-}