Example #1
0
 @Override
 public boolean equals(final Object o) {
   if (o == null || !(o instanceof Named)) {
     return false;
   }
   final Named other = (Named) o;
   return this.m_name.equals(other.getName());
 }
 /**
  * Create new NeamedIterator that gets populated with the value of Vector <code>v</code>. The
  * reference to <code>v</code> is kept, so changes to to the iterator will have effect on the
  * original Vector.
  */
 public NamedIterator(Vector v) {
   data = v; // same _pointer_: changes will have effect in original Vector
   hash = new Hashtable();
   for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
     Named n = (Named) e.nextElement();
     hash.put(n.getName(), n);
   }
   reset();
 }
 /** Removes an element from the iterator-list. */
 public void remove(Named n) {
   if (!readonly) {
     synchronized (this) {
       data.addElement(n);
       hash.put(n.getName(), n);
     }
   }
 }
 /** Adds an element at the current position. */
 public void addHere(Named n) {
   if (!readonly) {
     synchronized (this) {
       data.insertElementAt(n, pos);
       hash.put(n.getName(), n);
     }
   }
 }
  @Test
  public void typedRouterPattern() {
    try {
      // #typed-router
      // prepare routees
      TypedActorExtension typed = TypedActor.get(system);

      Named named1 = typed.typedActorOf(new TypedProps<Named>(Named.class));

      Named named2 = typed.typedActorOf(new TypedProps<Named>(Named.class));

      List<Named> routees = new ArrayList<Named>();
      routees.add(named1);
      routees.add(named2);

      List<String> routeePaths = new ArrayList<String>();
      routeePaths.add(typed.getActorRefFor(named1).path().toStringWithoutAddress());
      routeePaths.add(typed.getActorRefFor(named2).path().toStringWithoutAddress());

      // prepare untyped router
      ActorRef router = system.actorOf(new RoundRobinGroup(routeePaths).props(), "router");

      // prepare typed proxy, forwarding MethodCall messages to `router`
      Named typedRouter = typed.typedActorOf(new TypedProps<Named>(Named.class), router);

      System.out.println("actor was: " + typedRouter.name()); // name-243
      System.out.println("actor was: " + typedRouter.name()); // name-614
      System.out.println("actor was: " + typedRouter.name()); // name-243
      System.out.println("actor was: " + typedRouter.name()); // name-614

      // #typed-router
      typed.poisonPill(named1);
      typed.poisonPill(named2);
      typed.poisonPill(typedRouter);

    } catch (Exception e) {
      // dun care
    }
  }
Example #6
0
 public void testGetSetFamilyName() {
   assertEquals("Nordmann", named1.getFamilyName());
   assertEquals("Nordmann", named2.getFamilyName());
   named1.setFamilyName("Askeladd");
   named2.setFamilyName("Askeladd");
   assertEquals("Askeladd", named1.getFamilyName());
   assertEquals("Askeladd", named2.getFamilyName());
 }
Example #7
0
 public void testGetSetGivenName() {
   assertEquals("Ola", named1.getGivenName());
   assertEquals("Ola", named2.getGivenName());
   named1.setGivenName("Espen");
   named2.setGivenName("Espen");
   assertEquals("Espen", named1.getGivenName());
   assertEquals("Espen", named2.getGivenName());
 }
  protected Named findMember(Named container, String name) throws SemanticException {
    if (container instanceof ClassType) {
      ClassType ct = (ClassType) container;

      if (Report.should_report(report_topics, 2)) Report.report(2, "MCR: found prefix " + ct);

      // Uncomment if we should search superclasses
      // return ct.resolver().find(name);
      Named n = ct.memberClassNamed(name);

      if (n != null) {
        if (Report.should_report(report_topics, 2))
          Report.report(2, "MCR: found member of " + ct + ": " + n);
        return n;
      }
    }

    throw new NoClassException(container.fullName() + "." + name);
  }
Example #9
0
 /**
  * Adds a partition of a timed value to the spec.
  *
  * @param name the name of the partition
  * @param part the partition itself
  */
 public void addTimedPartition(String name, Partition<Timed<T>> part) {
   partitions.add(Named.create(name, part));
 }
Example #10
0
 /**
  * Adds a partition to the spec. If time is part of the partition criterion, use {@link
  * addTimedPartition} instead
  *
  * @param name the name of the partition
  * @param part the partition itself
  */
 public void addPartition(String name, Partition<T> part) {
   partitions.add(Named.create(name, part.lift(Timed.<T>valueFunction())));
 }
Example #11
0
 /**
  * Adds a statistic to the spec
  *
  * @param name the name of the statistic
  * @param stat the statistic itself
  */
 public void addStatistic(String name, Statistic<T> stat) {
   statistics.add(Named.create(name, stat));
 }
Example #12
0
 /** @return a list of all the statistic names */
 public List<String> statisticNames() {
   return Named.getNames(statistics);
 }
Example #13
0
 /** @return a list of all the partition names */
 public List<String> partitionNames() {
   return Named.getNames(partitions);
 }
Example #14
0
 public String getAliasForTableName(Named named) {
   return getAliasForTableName(named.getName());
 }
Example #15
0
 public void test_of() {
   SampleNamed test = Named.of(SampleNamed.class, "Standard");
   assertEquals(test, SampleNameds.STANDARD);
   assertThrowsIllegalArg(() -> Named.of(SampleNamed.class, "Rubbish"));
 }
Example #16
0
 @Override
 public String getName() {
   return Named.super.getName();
 }
Example #17
0
 /**
  * Adds a time partition to the spec (not to be confused with {@link addTimedPartition})
  *
  * @param name the name of the partition
  * @param part the partition itself
  */
 public void addTimePartition(String name, Partition<Double> part) {
   partitions.add(Named.create(name, part.lift(Timed.<T>timeFunction())));
 }
 public static <T> Map.Entry<String, T> namedValue(Named<T> name, T value) {
   return keyValue(name.id(), value);
 }
 @Before
 public void setUp() throws Exception {
   super.setUp();
 }