@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LinkSite that = (LinkSite) o; return type.equals(that.type) && field.equals(that.field); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LinkSite that = (LinkSite) o; return type.equals(that.type) && field.equals(that.field); }
/** * <p>Injects and associates the listener with a specific field for a given * component type.</p> * * <p>Each <code>ComponentType::Field</code> pair can only have one {@link LinkListener}</p> * * @param component component type associated with listener * @param field target field for listener * @param listener link listener */ public void register(Class<? extends Component> component, String field, LinkListener listener) { world.inject(listener); try { Field f = (field != null) ? ClassReflection.getDeclaredField(component, field) : null; ComponentType ct = world.getComponentManager().getTypeFactory().getTypeFor(component); for (LinkSite site : linkSites) { if (ct.equals(site.type) && (f == null || site.field.equals(f))) { site.listener = listener; if (!decoratedLinkSites.contains(site)) decoratedLinkSites.add(site); if (fireEventsOnRegistration) site.inserted(site.subscription.getEntities()); } } } catch (ReflectionException e) { throw new RuntimeException(e); } }
/** * <p>Injects and associates the listener with a specific field for a given * component type.</p> * * <p>Each <code>ComponentType::Field</code> pair can only have one {@link LinkListener}</p> * * @param component component type associated with listener * @param field target field for listener * @param listener link listener */ public void register(Class<? extends Component> component, String field, LinkListener listener) { world.inject(listener); try { Field f = (field != null) ? ClassReflection.getDeclaredField(component, field) : null; ComponentType ct = world.getComponentManager().getTypeFactory().getTypeFor(component); for (LinkSite site : linkSites) { if (ct.equals(site.type) && (f == null || site.field.equals(f))) { site.listener = listener; if (!decoratedLinkSites.contains(site)) decoratedLinkSites.add(site); if (fireEventsOnRegistration) site.inserted(site.subscription.getEntities()); } } } catch (ReflectionException e) { throw new RuntimeException(e); } }