/** * Determine if a {@link ScopeWrapper} is an ancestor of another {@link ScopeWrapper}. */ static <S extends ScopeType<S>> boolean isScopeAncestor(ScopeWrapper<S> scope, ScopeWrapper<S> possibleAncestor) { Queue<ScopeWrapper<S>> ancestors = new LinkedList<>(); ancestors.add(scope); while (true) { if (ancestors.isEmpty()) { return false; } if (ancestors.peek().equals(possibleAncestor)) { return true; } ancestors.addAll(ancestors.poll().getParentScopes()); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SharedResourcesBrokerImpl<?> that = (SharedResourcesBrokerImpl<?>) o; if (!brokerCache.equals(that.brokerCache)) { return false; } if (!ancestorScopesByType.equals(that.ancestorScopesByType)) { return false; } return selfScopeWrapper != null ? selfScopeWrapper.equals(that.selfScopeWrapper) : that.selfScopeWrapper == null; }
/** * Determine if a {@link ScopeWrapper} is an ancestor of another {@link ScopeWrapper}. */ static <S extends ScopeType<S>> boolean isScopeAncestor(ScopeWrapper<S> scope, ScopeWrapper<S> possibleAncestor) { Queue<ScopeWrapper<S>> ancestors = new LinkedList<>(); ancestors.add(scope); while (true) { if (ancestors.isEmpty()) { return false; } if (ancestors.peek().equals(possibleAncestor)) { return true; } ancestors.addAll(ancestors.poll().getParentScopes()); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SharedResourcesBrokerImpl<?> that = (SharedResourcesBrokerImpl<?>) o; if (!brokerCache.equals(that.brokerCache)) { return false; } if (!ancestorScopesByType.equals(that.ancestorScopesByType)) { return false; } return selfScopeWrapper != null ? selfScopeWrapper.equals(that.selfScopeWrapper) : that.selfScopeWrapper == null; }