net.digitalid.utility.validation.annotations.type.Mutable类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中net.digitalid.utility.validation.annotations.type.Mutable类的一些代码示例,展示了Mutable类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mutable类的具体详情如下:
包路径:net.digitalid.utility.validation.annotations.type.Mutable
类名称:Mutable

Mutable介绍

暂无

代码示例

代码示例来源:origin: net.digitalid.utility/utility-interfaces

/**
 * Classes with a non-reentrant lock should implement this interface.
 */
@Mutable
public interface Locking {
  
  /**
   * Returns whether the lock is held by the current thread.
   */
  @Pure
  public boolean isLockHeldByCurrentThread();
  
}

代码示例来源:origin: net.digitalid.utility/utility-rootclass

/**
 * The root class for all custom classes whose initialization does not throw a checked exception.
 */
@Mutable
public abstract class RootClass extends RootClassWithException<RuntimeException> {}

代码示例来源:origin: net.digitalid.utility/utility-concurrency

/**
 * Extends Java's {@link java.util.Set} interface.
 * 
 * @param <E> the type of the elements of this set.
 * 
 * @see ConcurrentHashSet
 */
@Mutable
public interface ConcurrentSet<E> extends Set<E> {}

代码示例来源:origin: net.digitalid.utility/utility-validation

/**
 * This interface allows to validate the invariant of implementing classes.
 */
@Mutable
public interface Validatable {
  
  /**
   * Validates the invariant and all non-private fields of this object.
   * Typically, the programmer implements this method to check all non-
   * trivial invariants which cannot be expressed through annotations
   * and the field checks are generated by an annotation processor in
   * a subclass by overriding this method and calling the supermethod.
   * 
   * @throws InvariantException if the invariant is violated.
   */
  @Pure
  @CallSuper
  public default void validate() {}
  
}

代码示例来源:origin: net.digitalid.utility/utility-casting

/**
 * This interface provides an easy way to cast an object to a subclass.
 */
@Mutable
public interface Castable {
  
  /* -------------------------------------------------- Casting -------------------------------------------------- */
  
  /**
   * Casts this object to the given target class.
   * 
   * @require targetClass.isInstance(this) : "This object is an instance of the given target class.";
   */
  @Pure
  public default @Chainable <T> @Nonnull T castTo(@Nonnull Class<T> targetClass) {
    Require.that(targetClass.isInstance(this)).orThrow("This object $ has to be an instance of the target class $.", this, targetClass);
    
    return targetClass.cast(this);
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-rootclass

/**
 * All custom interfaces in the Digital ID Library extend this root interface.
 * 
 * @see RootClass
 */
@Mutable
public interface RootInterface extends Castable, Validatable {
  
  /* -------------------------------------------------- Object -------------------------------------------------- */
  
  // The following methods will always be implemented by classes but are important when generating an implementation directly from an interface.
  
  @Pure
  @Override
  public boolean equals(@Nullable Object object);
  
  @Pure
  @Override
  public int hashCode();
  
  @Pure
  @Override
  public @Nonnull String toString();
  
}

代码示例来源:origin: net.digitalid.utility/utility-validation

/**
 * This class checks whether the annotation handler logs an error.
 */
@Mutable
public static class Logger extends ErrorLogger {
  
  private Logger() {}
  
  private boolean correctlyUsed = true;
  
  /**
   * Returns whether the annotation is used correctly.
   */
  @Pure
  public boolean isCorrectlyUsed() {
    return correctlyUsed;
  }
  
  @Impure
  @Override
  public void log(@Nonnull CharSequence message, @Nullable SourcePosition position, @NonCaptured @Unmodified @Nonnull @NullableElements Object... arguments) {
    this.correctlyUsed = false;
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-tuples

@Mutable
public class Iterator implements java.util.Iterator<Object> {
  
  private int cursor = 0;
  
  @Pure
  @Override
  public boolean hasNext() {
    return cursor < size();
  }
  
  @Impure
  @Override
  public @NonCapturable Object next() {
    if (hasNext()) { return get(cursor++); }
    else { throw new NoSuchElementException(); }
  }
  
  @Pure
  @Override
  public void remove() {
    throw new UnsupportedOperationException();
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-logging

/**
 * This class implements a logger that logs the messages to the standard output.
 */
@Mutable
public class StandardOutputLogger extends PrintStreamLogger {
  
  /* -------------------------------------------------- Constructors -------------------------------------------------- */
  
  /**
   * Creates a standard output logger that logs the messages to the standard output.
   */
  @SuppressWarnings("UseOfSystemOutOrSystemErr")
  protected StandardOutputLogger() {
    super(System.out);
  }
  
  /**
   * Returns a standard output logger that logs the messages to the standard output.
   */
  @Pure
  public static @Capturable @Nonnull StandardOutputLogger withNoArguments() {
    return new StandardOutputLogger();
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-immutable

/**
 * This class implements a builder for the immutable map.
 */
@Mutable
public static class ImmutableMapBuilder<K, V> extends LinkedHashMap<K, V> {
  
  /**
   * Adds the given key-value pair to this builder and returns itself.
   */
  @Impure
  @Chainable
  public @NonCapturable @Nonnull ImmutableMapBuilder<K, V> with(@Captured K key, @Captured V value) {
    put(key, value);
    return this;
  }
  
  /**
   * Returns an immutable map with the key-value pairs of this builder.
   */
  @Pure
  public @Nonnull ImmutableMap<K, V> build() {
    return ImmutableMap.withMappingsOf(this);
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-concurrency

/**
 * Extends Java's {@link java.util.concurrent.ConcurrentMap ConcurrentMap} interface with useful methods.
 * 
 * @param <K> the type of the keys of this map.
 * @param <V> the type of the values of this map.
 * 
 * @see ConcurrentHashMap
 */
@Mutable
public interface ConcurrentMap<K, V> extends java.util.concurrent.ConcurrentMap<K, V>, Cloneable {
  
  /**
   * Associates the given value with the given key, if the
   * given key is not already associated with another value.
   * 
   * @return the value that is now associated with the given key.
   */
  @Impure
  public @NonCapturable @Nonnull V putIfAbsentElseReturnPresent(@Captured @Nonnull K key, @Captured @Nonnull V value);
  
  /* -------------------------------------------------- Cloneable -------------------------------------------------- */
  
  /**
   * Returns a shallow copy of this map (the keys and values themselves are not cloned).
   */
  @Pure
  public @Capturable @Nonnull ConcurrentMap<K, V> clone();
  
}

代码示例来源:origin: net.digitalid.utility/utility-immutable

/**
 * This class implements an iterator that returns only read-only entries.
 */
@Mutable
public class ReadOnlyEntrySetIterator<K, V> extends ReadOnlyIterableIterator<Map.@Nonnull Entry<K, V>> {
  
  /* -------------------------------------------------- Constructors -------------------------------------------------- */
  
  protected ReadOnlyEntrySetIterator(@Captured @Nonnull Iterator<? extends Map.@Nonnull Entry<K, V>> iterator) {
    super(iterator);
  }
  
  /* -------------------------------------------------- Operations -------------------------------------------------- */
  
  @Impure
  @Override
  public @Nonnull ReadOnlyEntry<K, V> next() {
    return new ReadOnlyEntry<>(super.next());
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-processor

/**
 * An import group collects all the import statements of a given prefix.
 */
@Mutable
private static class ImportGroup {
  
  final @Nonnull String prefix;
  
  ImportGroup(@Nonnull String prefix) {
    this.prefix = prefix;
  }
  
  final @Nonnull Set<@Nonnull String> imports = new HashSet<>();
  
}

代码示例来源:origin: net.digitalid.utility/utility-processing

/**
 * This class allows to inject other behavior into the usage checks of annotation handlers for testing.
 * This class extends {@link ProcessingLog} only for being able to call {@link ProcessingLog#log(net.digitalid.utility.logging.Level, java.lang.CharSequence, net.digitalid.utility.processing.logging.SourcePosition, java.lang.Object...)} directly.
 */
@Mutable
public class ErrorLogger extends ProcessingLog {
  
  /**
   * Stores an immutable instance of the error logger, which can be shared.
   */
  public static final @Nonnull ErrorLogger INSTANCE = new ErrorLogger();
  
  /**
   * Logs the given message with the given position as an error.
   * Each dollar sign in the message is replaced with the corresponding argument.
   */
  @Impure
  public void log(@Nonnull CharSequence message, @Nullable SourcePosition position, @NonCaptured @Unmodified @Nonnull @NullableElements Object... arguments) {
    log(Level.ERROR, message, position, arguments);
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-logging

@Mutable
public abstract class LoggingFilter {

代码示例来源:origin: net.digitalid.utility/utility-functional

/**
 * This interface models an iterator that returns an infinite number of elements.
 */
@Mutable
public abstract class InfiniteIterator<@Specifiable ELEMENT> extends ReadOnlyIterator<ELEMENT> {
  
  /* -------------------------------------------------- Overridden Operations -------------------------------------------------- */
  
  @Pure
  @Override
  public final boolean hasNext() {
    return true;
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-processor

/**
 * This annotation processor generates the service loader entry for other annotation processors.
 */
@Mutable
@SupportedAnnotations(SupportedAnnotations.class)
public class ProcessorProcessor extends CustomProcessor {
  
  /* -------------------------------------------------- Processing -------------------------------------------------- */
  
  @Impure
  @Override
  public void processFirstRound(@Nonnull FiniteIterable<@Nonnull ? extends TypeElement> annotations, @Nonnull RoundEnvironment roundEnvironment) {
    final @Nonnull ServiceFileGenerator serviceLoaderFile = ServiceFileGenerator.forService(Processor.class);
    for (@Nonnull Element annotatedElement : roundEnvironment.getElementsAnnotatedWith(SupportedAnnotations.class)) {
      serviceLoaderFile.addProvider(annotatedElement);
    }
    serviceLoaderFile.write();
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-functional

/**
 * This class models an iterator whose elements cannot be removed.
 */
@Mutable
public abstract class ReadOnlyIterator<@Specifiable ELEMENT> implements Iterator<ELEMENT> {
  
  /* -------------------------------------------------- Supported Operations -------------------------------------------------- */
  
  @Pure
  @Override
  public abstract boolean hasNext() throws IterationException;
  
  @Impure
  @Override
  public abstract ELEMENT next() throws IterationException, NoSuchElementException;
  
  /* -------------------------------------------------- Unsupported Operations -------------------------------------------------- */
  
  @Pure
  @Override
  public final void remove() throws  UnsupportedOperationException {
    throw new UnsupportedOperationException();
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-concurrency

@Mutable
private static class Iterator<@Specifiable ELEMENT> extends ReadOnlyIterator<ELEMENT> {
  
  private @Nullable Node<ELEMENT> nextNode;
  
  @Pure
  @Override
  public boolean hasNext() {
    return nextNode != null;
  }
  
  @Impure
  @Override
  public ELEMENT next() throws NoSuchElementException {
    if (nextNode == null) { throw new NoSuchElementException(); }
    final ELEMENT result = nextNode.element;
    this.nextNode = nextNode.nextNode;
    return result;
  }
  
  private Iterator(@Nullable Node<ELEMENT> nextNode) {
    this.nextNode = nextNode;
  }
  
}

代码示例来源:origin: net.digitalid.utility/utility-rootclass

@Mutable
public abstract class RootClassWithException<@Unspecifiable EXCEPTION extends Exception> implements RootInterface {

相关文章

微信公众号

最新文章

更多

Mutable类方法