Пример #1
0
  public void unregisterPositionListener(@Nonnull String name) {
    NamedEntry.validateName(name);

    PositionListenerEntry positionListenerEntry;

    if (positionListenerEntryByName == null
        || (positionListenerEntry = positionListenerEntryByName.remove(name)) == null) {
      throw new IllegalArgumentException("Listener '" + name + "' is not registered.");
    }

    positionListenerEntries.remove(positionListenerEntry);
  }
Пример #2
0
  public void registerPositionListener(
      @Nonnull PositionListener listener, @Nonnull String name, double priority) {
    NamedEntry.validateName(name);

    if (positionListenerEntryByName == null) {
      positionListenerEntryByName = new HashMap<>(1);
      positionListenerEntries = new TreeSet<>(PositionListenerEntry.comparator);
    } else if (positionListenerEntryByName.containsKey(name)) {
      throw new IllegalArgumentException("Listener '" + name + "' is already registered.");
    }

    PositionListenerEntry positionListenerEntry =
        new PositionListenerEntry(name, priority, listener);
    positionListenerEntryByName.put(name, positionListenerEntry);
    positionListenerEntries.add(positionListenerEntry);
  }
Пример #3
0
 public boolean hasPositionListener(@Nonnull String name) {
   NamedEntry.validateName(name);
   return positionListenerEntryByName != null && positionListenerEntryByName.containsKey(name);
 }