From e023e674020f1a435f7b8c8b9276704f576ea6e5 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 29 Mar 2021 14:08:45 +0200 Subject: structure change 1 --- src/org/uic/barcode/asn1/datatypes/Alphabet.java | 20 ----- .../barcode/asn1/datatypes/AlphabetBuilder.java | 32 -------- .../barcode/asn1/datatypes/Asn1AnonymousType.java | 15 ---- .../uic/barcode/asn1/datatypes/Asn1BigInteger.java | 72 ---------------- .../uic/barcode/asn1/datatypes/Asn1Default.java | 12 --- .../uic/barcode/asn1/datatypes/Asn1Integer.java | 56 ------------- .../uic/barcode/asn1/datatypes/Asn1Optional.java | 20 ----- .../uic/barcode/asn1/datatypes/Asn1SequenceOf.java | 70 ---------------- src/org/uic/barcode/asn1/datatypes/Asn1String.java | 17 ---- .../asn1/datatypes/Asn1VarSizeBitstring.java | 58 ------------- src/org/uic/barcode/asn1/datatypes/Bitstring.java | 16 ---- .../asn1/datatypes/CharacterRestriction.java | 13 --- src/org/uic/barcode/asn1/datatypes/Choice.java | 12 --- .../barcode/asn1/datatypes/DefaultAlphabet.java | 8 -- src/org/uic/barcode/asn1/datatypes/FieldOrder.java | 13 --- src/org/uic/barcode/asn1/datatypes/FixedSize.java | 12 --- .../barcode/asn1/datatypes/HasExtensionMarker.java | 12 --- .../uic/barcode/asn1/datatypes/IntMinValue.java | 13 --- src/org/uic/barcode/asn1/datatypes/IntRange.java | 14 ---- .../uic/barcode/asn1/datatypes/IsExtension.java | 12 --- .../uic/barcode/asn1/datatypes/NoAsn1Field.java | 10 --- src/org/uic/barcode/asn1/datatypes/Optional.java | 96 ---------------------- .../barcode/asn1/datatypes/RestrictedString.java | 13 --- src/org/uic/barcode/asn1/datatypes/Sequence.java | 9 -- src/org/uic/barcode/asn1/datatypes/SizeRange.java | 14 ---- .../uic/barcode/asn1/datatypes/package-info.java | 7 -- 26 files changed, 646 deletions(-) delete mode 100644 src/org/uic/barcode/asn1/datatypes/Alphabet.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1AnonymousType.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1BigInteger.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1Default.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1Integer.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1Optional.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1SequenceOf.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1String.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Asn1VarSizeBitstring.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Bitstring.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/CharacterRestriction.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Choice.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/DefaultAlphabet.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/FieldOrder.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/FixedSize.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/HasExtensionMarker.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/IntMinValue.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/IntRange.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/IsExtension.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/NoAsn1Field.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Optional.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/RestrictedString.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/Sequence.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/SizeRange.java delete mode 100644 src/org/uic/barcode/asn1/datatypes/package-info.java (limited to 'src/org/uic/barcode/asn1/datatypes') diff --git a/src/org/uic/barcode/asn1/datatypes/Alphabet.java b/src/org/uic/barcode/asn1/datatypes/Alphabet.java deleted file mode 100644 index 2b153ae..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Alphabet.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -/** - * Alphabet class for Restricted Strings. - * - * Use {@link AlphabetBuilder} for convenient construction of restriction alphabets. - */ -public abstract class Alphabet { - - private final String chars; - - protected Alphabet(String chars) { - this.chars = chars; - } - - public final String chars() { - return chars; - } - -} diff --git a/src/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java b/src/org/uic/barcode/asn1/datatypes/AlphabetBuilder.java deleted file mode 100644 index b768897..0000000 --- a/src/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/org/uic/barcode/asn1/datatypes/Asn1AnonymousType.java b/src/org/uic/barcode/asn1/datatypes/Asn1AnonymousType.java deleted file mode 100644 index b1b0499..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1AnonymousType.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; -/** - * This annotation indicates that the class is not present in the original ASN.1 declaration. - * This happens when SEQUENCE members have restrictions (ranges, alphabets etc). - * - * This annotation plays no role in the UPER encoding. - * - */ -@Target({ElementType.TYPE}) -public @interface Asn1AnonymousType { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1BigInteger.java b/src/org/uic/barcode/asn1/datatypes/Asn1BigInteger.java deleted file mode 100644 index 4adca22..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1BigInteger.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.math.BigInteger; - -//outdated: use BigInteger -public class Asn1BigInteger { - - private final BigInteger value; - - public Asn1BigInteger(final BigInteger value) { - this.value = value; - } - - @Override public String toString() { - return "" + value; - } - - public BigInteger value() { return value; } - - public Long longValue() { - return value.longValue(); - } - - public Integer intValue() { - return value.intValue(); - } - - public Asn1BigInteger(Long num) { - this.value = BigInteger.valueOf(num); - } - - public Asn1BigInteger(long num) { - this.value = BigInteger.valueOf(num); - } - - public Asn1BigInteger(Integer num) { - this.value = BigInteger.valueOf(num); - } - - public Asn1BigInteger(int num) { - this.value = BigInteger.valueOf(num); - } - - public static Long toLong(Asn1BigInteger object) { - if (object == null) return null; - return object.longValue(); - } - - public static Asn1BigInteger toAsn1(Long object) { - if (object == null) return null; - return new Asn1BigInteger(object); - } - - public static Asn1BigInteger toAsn1(Integer object) { - if (object == null) return null; - return new Asn1BigInteger(object); - } - - public Long toLong(){ - if (this.value != null) { - return this.value.longValue(); - } - return null; - } - - public BigInteger toBigInteger(){ - return value; - } - - - -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1Default.java b/src/org/uic/barcode/asn1/datatypes/Asn1Default.java deleted file mode 100644 index bf5cfff..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1Default.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Asn1Default { - String value(); -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1Integer.java b/src/org/uic/barcode/asn1/datatypes/Asn1Integer.java deleted file mode 100644 index e12f8ec..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1Integer.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - - - -//outdated: use BigInteger -public class Asn1Integer { - - public long value; - - public Asn1Integer() {} - public Asn1Integer(long value) { - this.value = value; - } - - public Long value() { return value; } - - @Override public String toString() { - return "" + value; - } - - public Long longObject () { - return new Long(value()); - } - - public Asn1Integer(Long num) { - this.value = num; - } - - - public Asn1Integer(Integer num) { - this.value = num; - } - - public Asn1Integer(int num) { - this.value = num; - } - - public static Long toLong(Asn1Integer object) { - if (object == null) return null; - return object.value(); - } - - - public static Asn1Integer toAsn1(Long object) { - if (object == null) return null; - return new Asn1Integer(object); - } - - - - - - - - -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1Optional.java b/src/org/uic/barcode/asn1/datatypes/Asn1Optional.java deleted file mode 100644 index 71946ec..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1Optional.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that the field is OPTIONAL in ASN.1. Implemented as null. Equivalent to @Nullable. - * - * Using Optional would require Manifests to capture generics (like in Gson). - * - */ -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Asn1Optional { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1SequenceOf.java b/src/org/uic/barcode/asn1/datatypes/Asn1SequenceOf.java deleted file mode 100644 index 4924b50..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1SequenceOf.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.reflect.ParameterizedType; -import java.util.*; - -import org.uic.barcode.logger.Logger; -import org.uic.barcode.logger.LoggerFactory; - - -/** - * Class to represent ASN.1 construct "SEQUENCE OF". - *

- * Extending classes should specify concrete types for T, generic collections can't be decoded (yet?). - *

- * Usage example: - *

- * 
- * {@literal @}Sequence
- * public class Person {
- *     {@literal @}IntRange(minValue=0, maxValue=100, hasExtensionMarker=true)
- *     int age;
- *     Children children;
- * }
- * public class Children extends {@code Asn1SequenceOf } {
- *     public Children() { super(); }
- *     public Children({@code Collection} coll) { super(coll); }
- * }
- * 
- * 
- * - *

- * Actually, UPER decoder and encoder consider anything that extends {@code List} as a SEQUENCE OF. - * - * - * @param type of elements contained. - */ -public abstract class Asn1SequenceOf extends AbstractList { - private final static Logger logger = LoggerFactory.getLogger("asnLogger"); - - private final List bakingList; - - @Override public T get(int index) { return bakingList.get(index); } - @Override public int size() { return bakingList.size(); } - @Override public boolean add (T e){ return bakingList.add(e);} - - public Asn1SequenceOf() { this(new ArrayList()); } - public Asn1SequenceOf(Collection coll) { - logger.debug(String.format("Instantiating Sequence Of %s with %s", - ((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0], - coll)); - bakingList = new ArrayList<>(coll); - } - - - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - Asn1SequenceOf that = (Asn1SequenceOf) o; - return Objects.equals(bakingList, that.bakingList); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), bakingList); - } -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1String.java b/src/org/uic/barcode/asn1/datatypes/Asn1String.java deleted file mode 100644 index fb80b92..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1String.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -public class Asn1String { - - private String value; - - public Asn1String() { this(""); } - - public Asn1String(String value) { - this.value = value; - } - - @Override public String toString() { return value; } - - public String value() { return value; } - -} diff --git a/src/org/uic/barcode/asn1/datatypes/Asn1VarSizeBitstring.java b/src/org/uic/barcode/asn1/datatypes/Asn1VarSizeBitstring.java deleted file mode 100644 index c07f7f0..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Asn1VarSizeBitstring.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.util.AbstractList; -import java.util.BitSet; -import java.util.Collection; -import java.util.Objects; - -/** - * Convenience class for Bitstrings of variable size. - * For UPER, {@code List} works just as well. - */ -public class Asn1VarSizeBitstring extends AbstractList { - - private final BitSet backing; - - @Override public Boolean get(int index) { - return backing.get(index); - } - - @Override public int size() { - return backing.length(); - } - - public Asn1VarSizeBitstring(Collection coll) { - backing = new BitSet(); - int bitIndex = 0; - for (Boolean b : coll) { - backing.set(bitIndex, b); - bitIndex++; - } - } - - public Asn1VarSizeBitstring(BitSet bitset) { - backing = (BitSet) bitset.clone(); - } - - protected void setBit(int bitIndex, boolean value) { - backing.set(bitIndex, value); - } - - public boolean getBit(int bitIndex) { - return backing.get(bitIndex); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - Asn1VarSizeBitstring booleen = (Asn1VarSizeBitstring) o; - return Objects.equals(backing, booleen.backing); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), backing); - } -} diff --git a/src/org/uic/barcode/asn1/datatypes/Bitstring.java b/src/org/uic/barcode/asn1/datatypes/Bitstring.java deleted file mode 100644 index 1543f64..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Bitstring.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** This annotation is used for bitstrings. - * In UPER, a SEQUENCE OF Booleans would look exactly as bitstring, so this annotation can be - * omitted for {@code List}. - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Bitstring { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/CharacterRestriction.java b/src/org/uic/barcode/asn1/datatypes/CharacterRestriction.java deleted file mode 100644 index e74c436..0000000 --- a/src/org/uic/barcode/asn1/datatypes/CharacterRestriction.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -public enum CharacterRestriction { - NumericString, - PrintableString, - VisibleString, - ISO646String, - IA5String, - BMPString, - UniversalString, - UTF8String, - ObjectIdentifier; -} diff --git a/src/org/uic/barcode/asn1/datatypes/Choice.java b/src/org/uic/barcode/asn1/datatypes/Choice.java deleted file mode 100644 index 01a0034..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Choice.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Choice { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/DefaultAlphabet.java b/src/org/uic/barcode/asn1/datatypes/DefaultAlphabet.java deleted file mode 100644 index 62d13f4..0000000 --- a/src/org/uic/barcode/asn1/datatypes/DefaultAlphabet.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -public class DefaultAlphabet extends Alphabet { - - public DefaultAlphabet() { - super(""); - } -} diff --git a/src/org/uic/barcode/asn1/datatypes/FieldOrder.java b/src/org/uic/barcode/asn1/datatypes/FieldOrder.java deleted file mode 100644 index b8c378f..0000000 --- a/src/org/uic/barcode/asn1/datatypes/FieldOrder.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface FieldOrder { - int order() default -1; -} - diff --git a/src/org/uic/barcode/asn1/datatypes/FixedSize.java b/src/org/uic/barcode/asn1/datatypes/FixedSize.java deleted file mode 100644 index 4c17e60..0000000 --- a/src/org/uic/barcode/asn1/datatypes/FixedSize.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface FixedSize { - int value(); -} diff --git a/src/org/uic/barcode/asn1/datatypes/HasExtensionMarker.java b/src/org/uic/barcode/asn1/datatypes/HasExtensionMarker.java deleted file mode 100644 index b8945fc..0000000 --- a/src/org/uic/barcode/asn1/datatypes/HasExtensionMarker.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface HasExtensionMarker { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/IntMinValue.java b/src/org/uic/barcode/asn1/datatypes/IntMinValue.java deleted file mode 100644 index e045287..0000000 --- a/src/org/uic/barcode/asn1/datatypes/IntMinValue.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface IntMinValue { - long minValue(); - boolean hasExtensionMarker() default false; -} diff --git a/src/org/uic/barcode/asn1/datatypes/IntRange.java b/src/org/uic/barcode/asn1/datatypes/IntRange.java deleted file mode 100644 index 08fc1fb..0000000 --- a/src/org/uic/barcode/asn1/datatypes/IntRange.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface IntRange { - long minValue(); - long maxValue(); - boolean hasExtensionMarker() default false; -} diff --git a/src/org/uic/barcode/asn1/datatypes/IsExtension.java b/src/org/uic/barcode/asn1/datatypes/IsExtension.java deleted file mode 100644 index 8aacd32..0000000 --- a/src/org/uic/barcode/asn1/datatypes/IsExtension.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface IsExtension { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/NoAsn1Field.java b/src/org/uic/barcode/asn1/datatypes/NoAsn1Field.java deleted file mode 100644 index 0fb7d2c..0000000 --- a/src/org/uic/barcode/asn1/datatypes/NoAsn1Field.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface NoAsn1Field {} \ No newline at end of file diff --git a/src/org/uic/barcode/asn1/datatypes/Optional.java b/src/org/uic/barcode/asn1/datatypes/Optional.java deleted file mode 100644 index 757ba29..0000000 --- a/src/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 type of contained elements */ -public class Optional { - - 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: - *

- * - * @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 the type of the value - * @param element contained value - * @return a new Option that contains the value */ - public static Optional of(final A element) { - return new Optional(element, true); - } - - /** Returns an empty option. - * - * @param - * @return an empty Option */ - public static Optional empty() { - return new Optional(null, false); - } -} diff --git a/src/org/uic/barcode/asn1/datatypes/RestrictedString.java b/src/org/uic/barcode/asn1/datatypes/RestrictedString.java deleted file mode 100644 index 7539aed..0000000 --- a/src/org/uic/barcode/asn1/datatypes/RestrictedString.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface RestrictedString { - CharacterRestriction value(); - Class alphabet() default DefaultAlphabet.class; -} diff --git a/src/org/uic/barcode/asn1/datatypes/Sequence.java b/src/org/uic/barcode/asn1/datatypes/Sequence.java deleted file mode 100644 index 31163d7..0000000 --- a/src/org/uic/barcode/asn1/datatypes/Sequence.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.uic.barcode.asn1.datatypes; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -//@Target({ElementType.ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Sequence { - -} diff --git a/src/org/uic/barcode/asn1/datatypes/SizeRange.java b/src/org/uic/barcode/asn1/datatypes/SizeRange.java deleted file mode 100644 index 7005d47..0000000 --- a/src/org/uic/barcode/asn1/datatypes/SizeRange.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.uic.barcode.asn1.datatypes; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.TYPE, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface SizeRange { - int minValue(); - int maxValue(); - boolean hasExtensionMarker() default false; -} diff --git a/src/org/uic/barcode/asn1/datatypes/package-info.java b/src/org/uic/barcode/asn1/datatypes/package-info.java deleted file mode 100644 index aaa134e..0000000 --- a/src/org/uic/barcode/asn1/datatypes/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** Annotations to create Java classes that correspond to ASN.1 specifications. - * - * Some annotations (e.g. {@link SizeRange}, {@link FixedSize}, {@link IntRange},{@link IntMaxValue} - * {@link RestrictedString}) are Type-only annotations and sometime require creating extra classes, - * they can be extended to work as Field annotations too, but this will require modifications to the - * Encoder. */ -package org.uic.barcode.asn1.datatypes; -- cgit v1.2.3