/** * 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()); }
@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(); } } }
@Override public String toString() { return "<" + fst.toString() + ", " + snd.toString() + ">"; }
void f() { A c = new A(); c.toString(); }
/** * {@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; }