예제 #1
0
파일: Lists.java 프로젝트: roggen/roggen
 /**
  * Inserts the given element after the reference. Throws {@link NoSuchElementException} if the
  * list does not contain the reference
  *
  * @param <A> the list type
  * @param list the list
  * @param element the element to be inserted just afeter the reference element
  * @param reference the reference. The list must contain it
  */
 public static <A> void addAfter(@NonNull List<A> list, A element, A reference) {
   for (ListIterator<A> iter = list.listIterator(); iter.hasNext(); )
     if (ObjectUtils.equals(iter.next(), reference)) {
       iter.add(element);
       return;
     }
   throw new NoSuchElementException(reference.toString());
 }
예제 #2
0
  @Override
  public void run() {

    while (continueWorking) {

      try {
        A a = queue.take();
        System.out.println("RECEIVED " + a.toString());
        ClientConnection cc = new ClientConnection(a);
        cc.start();
      } catch (InterruptedException ex) {

        this.dgSocket.close();
        this.continueWorking = false;
        this.child.valid = false;
        this.child.interrupt();
        this.interrupt();
      }
    }
  }
예제 #3
0
 @Override
 public String toString() {
   return "<" + fst.toString() + ", " + snd.toString() + ">";
 }
예제 #4
0
 void f() {
   A c = new A();
   c.toString();
 }
예제 #5
0
  /**
   * {@inheritDoc}
   *
   * @see org.castor.core.annotationprocessing.TargetAwareAnnotationProcessor#
   *     processAnnotation(BaseNature, Annotation, AnnotatedElement)
   */
  public <I extends BaseNature, A extends Annotation> boolean processAnnotation(
      final I info, final A annotation, final AnnotatedElement target)
      throws AnnotationTargetException {
    if ((info instanceof JPAFieldNature)
        && (annotation instanceof OneToMany)
        && ((target instanceof Method) || (target instanceof Field))) {
      _log.debug("processing field annotation " + annotation.toString());

      JPAFieldNature jpaFieldNature = (JPAFieldNature) info;

      OneToMany oneToMany = (OneToMany) annotation;

      /*
       * @OneToMany.targetEntity
       */

      Class<?> collectionType;
      try {
        collectionType = ReflectionsHelper.getCollectionType(target, true);
      } catch (AnnotationTargetException e) {
        _log.error(e.getMessage());
        throw e;
      }

      Class<?> targetEntity = oneToMany.targetEntity();
      if (void.class.equals(targetEntity)) {
        try {
          targetEntity = ReflectionsHelper.getTargetEntityFromGenerics(target);
          if (targetEntity == null) {
            // Error => no generics used!
            String className = ((Member) target).getDeclaringClass().getName();
            String targetName = ((Member) target).getName();
            String message =
                "Target entity for OneToMany relation on "
                    + className
                    + "#"
                    + targetName
                    + " not specified - use generics or specify targetEntity!";
            throw new AnnotationTargetException(message);
          }
        } catch (AnnotationTargetException e) {
          _log.error(e.getMessage());
          throw e;
        }
      }

      jpaFieldNature.setRelationTargetEntity(targetEntity);
      jpaFieldNature.setRelationCollectionType(collectionType);

      /*
       * @OneToMany.cascade
       */
      if (oneToMany.cascade().length > 0) {
        jpaFieldNature.setCascadeTypes(oneToMany.cascade());
      }

      /*
       * @OneToMany.fetch
       */
      jpaFieldNature.setRelationLazyFetch(false);
      if (oneToMany.fetch() == FetchType.LAZY) {
        jpaFieldNature.setRelationLazyFetch(true);
      }

      /*
       * @OneToMany.mappedBy
       */
      if (oneToMany.mappedBy().length() != 0) {
        jpaFieldNature.setRelationMappedBy(oneToMany.mappedBy());
      }

      jpaFieldNature.setOneToMany(true);

      return true;
    }

    return false;
  }