public final ShapeImpl applyTransition(Transition transition, boolean append) { if (transition instanceof AddPropertyTransition) { return append ? append(((AddPropertyTransition) transition).getProperty()) : addProperty(((AddPropertyTransition) transition).getProperty()); } else if (transition instanceof ObjectTypeTransition) { return changeType(((ObjectTypeTransition) transition).getObjectType()); } else if (transition instanceof ReservePrimitiveArrayTransition) { return reservePrimitiveExtensionArray(); } else { throw new UnsupportedOperationException(); } }
/** @since 0.17 or earlier */ protected ShapeImpl applyTransition(ShapeImpl shape, Transition transition, boolean append) { if (transition instanceof AddPropertyTransition) { Property property = ((AddPropertyTransition) transition).getProperty(); if (append) { return shape.append(property); } else { shape.onPropertyTransition(property); return addProperty(shape, property, false); } } else if (transition instanceof ObjectTypeTransition) { return shape.changeType(((ObjectTypeTransition) transition).getObjectType()); } else if (transition instanceof ReservePrimitiveArrayTransition) { return shape.reservePrimitiveExtensionArray(); } else if (transition instanceof DirectReplacePropertyTransition) { Property oldProperty = ((DirectReplacePropertyTransition) transition).getPropertyBefore(); Property newProperty = ((DirectReplacePropertyTransition) transition).getPropertyAfter(); if (append) { oldProperty = shape.getProperty(oldProperty.getKey()); newProperty = newProperty.relocate(shape.allocator().moveLocation(newProperty.getLocation())); } return directReplaceProperty(shape, oldProperty, newProperty); } else { throw new UnsupportedOperationException(transition.getClass().getName()); } }
/** @since 0.17 or earlier */ protected ShapeImpl applyTransition(ShapeImpl shape, Transition transition, boolean append) { if (transition instanceof AddPropertyTransition) { Property property = ((AddPropertyTransition) transition).getProperty(); if (append) { return shape.append(property); } else { shape.onPropertyTransition(property); return addProperty(shape, property, false); } } else if (transition instanceof ObjectTypeTransition) { return shape.changeType(((ObjectTypeTransition) transition).getObjectType()); } else if (transition instanceof ReservePrimitiveArrayTransition) { return shape.reservePrimitiveExtensionArray(); } else if (transition instanceof DirectReplacePropertyTransition) { Property oldProperty = ((DirectReplacePropertyTransition) transition).getPropertyBefore(); Property newProperty = ((DirectReplacePropertyTransition) transition).getPropertyAfter(); if (append) { oldProperty = shape.getProperty(oldProperty.getKey()); newProperty = newProperty.relocate(shape.allocator().moveLocation(newProperty.getLocation())); } return directReplaceProperty(shape, oldProperty, newProperty); } else { throw new UnsupportedOperationException(transition.getClass().getName()); } }