private static CopyHistory cacheObject(final CopyType lastOperation, final int operations) { final CopyHistory[] array = cacheArray(lastOperation); CopyHistory ret = array[operations]; if (ret == null) { synchronized (array) { ret = array[operations]; if (ret == null) { ret = new CopyHistory(operations, lastOperation); array[operations] = ret; } } } return ret; }
public static CopyHistory of(final CopyType copyType, final CopyHistory copyHistory) { return ORIGINAL.append(copyType, copyHistory); }
ActionEffectiveStatementImpl( final StmtContext<QName, ActionStatement, EffectiveStatement<QName, ActionStatement>> ctx) { super(ctx); // initCopyType final CopyHistory copyTypesFromOriginal = ctx.getCopyHistory(); if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) { this.augmenting = true; this.addedByUses = true; } else { this.augmenting = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION); this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES); } }
@Override public String toString() { return MoreObjects.toStringHelper(this).add("lastOperation", getLastOperation()) .add("operations", Arrays.stream(VALUES).filter(value -> (value.bit() & operations) != 0) .collect(Collectors.toList())) .toString(); } }
StatementContextBase(final StatementDefinitionContext<A, D, E> def, final StatementSourceReference ref, final String rawArgument) { this.definition = requireNonNull(def); this.statementDeclSource = requireNonNull(ref); this.rawArgument = def.internArgument(rawArgument); this.copyHistory = CopyHistory.original(); this.originalCtx = null; }
StatementContextBase(final StatementContextBase<A, D, E> original, final CopyType copyType) { this.definition = original.definition; this.statementDeclSource = original.statementDeclSource; this.rawArgument = original.rawArgument; this.copyHistory = CopyHistory.of(copyType, original.getCopyHistory()); this.originalCtx = original.getOriginalCtx().orElse(original); }
@VisibleForTesting CopyHistory append(final CopyType typeOfCopy, final CopyHistory toAppend) { final int newOperations = operations | toAppend.operations | typeOfCopy.bit(); if (newOperations == operations && typeOfCopy.ordinal() == lastOperation) { return this; } return cacheObject(typeOfCopy, newOperations); }
if (ctx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) { final Optional<StmtContext<?, ?, ?>> optOrigCtx = ctx.getOriginalCtx(); if (optOrigCtx.isPresent()) {
protected AbstractEffectiveDataSchemaNode(final StmtContext<QName, D, ?> ctx) { super(ctx); this.configuration = ctx.isConfiguration(); whenCondition = findFirstEffectiveSubstatementArgument(WhenEffectiveStatement.class).orElse(null); // initCopyType final CopyHistory originalHistory = ctx.getCopyHistory(); if (originalHistory.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) { this.augmenting = true; this.addedByUses = true; } else { this.augmenting = originalHistory.contains(CopyType.ADDED_BY_AUGMENTATION); this.addedByUses = originalHistory.contains(CopyType.ADDED_BY_USES); } }
qnameModule = StmtContextUtils.getRootModuleQName(ctx); if (qnameModule == null && ctx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) { ctx = ctx.getOriginalCtx().orElse(null); qnameModule = StmtContextUtils.getModuleQNameByPrefix(ctx, prefix);
protected AbstractEffectiveSimpleDataNodeContainer(final StmtContext<QName, D, ?> ctx) { super(ctx); this.path = ctx.getSchemaPath().get(); this.configuration = ctx.isConfiguration(); whenCondition = findFirstEffectiveSubstatementArgument(WhenEffectiveStatement.class).orElse(null); // initSubstatementCollectionsAndFields List<UnknownSchemaNode> unknownNodesInit = new ArrayList<>(); Set<AugmentationSchemaNode> augmentationsInit = new LinkedHashSet<>(); for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) { if (effectiveStatement instanceof UnknownSchemaNode) { unknownNodesInit.add((UnknownSchemaNode) effectiveStatement); } if (effectiveStatement instanceof AugmentationSchemaNode) { augmentationsInit.add((AugmentationSchemaNode) effectiveStatement); } } this.unknownNodes = ImmutableList.copyOf(unknownNodesInit); this.augmentations = ImmutableSet.copyOf(augmentationsInit); // initCopyType final CopyHistory copyTypesFromOriginal = ctx.getCopyHistory(); if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) { this.augmenting = true; this.addedByUses = true; } else { this.augmenting = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION); this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES); } }
GroupingEffectiveStatementImpl( final StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) { super(ctx); qname = ctx.coerceStatementArgument(); path = ctx.getSchemaPath().get(); addedByUses = ctx.getCopyHistory().contains(CopyType.ADDED_BY_USES); final ImmutableSet.Builder<ActionDefinition> actionsBuilder = ImmutableSet.builder(); final ImmutableSet.Builder<NotificationDefinition> notificationsBuilder = ImmutableSet.builder(); final ImmutableList.Builder<UnknownSchemaNode> b = ImmutableList.builder(); for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) { if (effectiveStatement instanceof ActionDefinition) { actionsBuilder.add((ActionDefinition) effectiveStatement); } if (effectiveStatement instanceof NotificationDefinition) { notificationsBuilder.add((NotificationDefinition) effectiveStatement); } if (effectiveStatement instanceof UnknownSchemaNode) { b.add((UnknownSchemaNode) effectiveStatement); } } this.actions = actionsBuilder.build(); this.notifications = notificationsBuilder.build(); unknownNodes = b.build(); }
addedByUses = ctx.getCopyHistory().contains(CopyType.ADDED_BY_USES);
if (copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) { this.addedByAugmentation = true; this.addedByUses = true; } else { this.addedByAugmentation = copyTypesFromOriginal.contains(CopyType.ADDED_BY_AUGMENTATION); this.addedByUses = copyTypesFromOriginal.contains(CopyType.ADDED_BY_USES);