public static boolean canIncorporate(CanonicalPath entityPath) { SegmentType entityType = entityPath.getSegment().getElementType(); SegmentType parentType = entityPath.up().getSegment().getElementType(); return SegmentType.t.equals(parentType) && (SegmentType.rt.equals(entityType) || SegmentType.mt.equals(entityType)); }
public RelationNotFoundException(SegmentType sourceEntityType, String nameOrId, Filter[][] filters, String message, Throwable cause) { this(sourceEntityType == null ? null : sourceEntityType.getSimpleName(), nameOrId, filters, message, cause); }
public static Class<? extends Entity> entityTypeFromSegmentType(SegmentType segmentType) { switch (segmentType) { case t: return Tenant.class; case e: return Environment.class; case f: return Feed.class; case m: return Metric.class; case mt: return MetricType.class; case r: return Resource.class; case rt: return ResourceType.class; // case rl: // return Relationship.class; case d: return DataEntity.class; case ot: return OperationType.class; case mp: return MetadataPack.class; default: throw new IllegalStateException("There is no " + Entity.class.getName() + " type for " + segmentType.getClass().getName() + " '" + segmentType.name() + "'"); } }
/** * Constructs a new entity * * @param name the human readable name of the entity, can be null * @param path the path of the entity, must not be null * @param properties the additional user-defined properties, can be null */ Entity(String name, CanonicalPath path, Map<String, Object> properties) { super(path, properties); this.name = name; if (!segmentTypeFromType(this.getClass()).equals(path.getSegment().getElementType())) { throw new IllegalArgumentException("Invalid path specified. Trying to create " + this.getClass().getSimpleName() + " but the path points to " + path.getSegment().getElementType().getSimpleName()); } }
public <U extends AbstractElement.Update> ElementTypes<?, ?, U> byUpdate(Class<U> updateType) { for(SegmentType st : SegmentType.values()) { ElementTypes ret = elementTypes.get(st); if (ret.getUpdateType().equals(updateType)) { return ret; } } throw new IllegalArgumentException("Unknown update type: " + updateType); }
private static String segmentToString(Path.Segment segment) { return (segment.getElementType() == null ? "" : (segment.getElementType().getSerialized() + ";")) + segment.getElementId(); } }
SegmentType parentType = absoluteParent.getSegment().getElementType(); SegmentType childSegment = SegmentType.fromElementType(childType);
/** * Constructs a new entity * * @param name the human readable name of the entity, can be null * @param path the path of the entity, must not be null * @param properties the additional user-defined properties, can be null */ Entity(String name, CanonicalPath path, Map<String, Object> properties) { super(path, properties); this.name = name; if (!segmentTypeFromType(this.getClass()).equals(path.getSegment().getElementType())) { throw new IllegalArgumentException("Invalid path specified. Trying to create " + this.getClass().getSimpleName() + " but the path points to " + path.getSegment().getElementType().getSimpleName()); } }
public <E extends AbstractElement<B, U>, B extends Blueprint, U extends AbstractElement.Update> ElementTypes<E, B, U> bySingle(Class<? extends ResolvableToSingle<E, U>> singleAccessorType) { for(SegmentType st : SegmentType.values()) { ElementTypes ret = elementTypes.get(st); if (ret.getSingleAccessorType().equals(singleAccessorType)) { return ret; } } throw new IllegalArgumentException("Unknown single accessor type: " + singleAccessorType); }
public static boolean canIncorporate(CanonicalPath entityPath) { SegmentType entityType = entityPath.getSegment().getElementType(); SegmentType parentType = entityPath.up().getSegment().getElementType(); return SegmentType.t.equals(parentType) && (SegmentType.rt.equals(entityType) || SegmentType.mt.equals(entityType)); }
public <E extends AbstractElement<B, U>, B extends Blueprint, U extends AbstractElement.Update> ElementTypes<E, B, U> byElement(Class<E> elementType) { for(SegmentType st : SegmentType.values()) { ElementTypes ret = elementTypes.get(st); if (ret.getElementType().equals(elementType)) { return ret; } } throw new IllegalArgumentException("Unknown element type: " + elementType); }
public EntityNotFoundException(SegmentType entityType, Filter[][] filters) { this(entityType == null ? null : entityType.getSimpleName(), filters); }
public static Class<? extends Entity<? extends org.hawkular.inventory.api.model.Blueprint, ?>> entityTypeFromSegmentType(SegmentType segmentType) { switch (segmentType) { case t: return Tenant.class; case e: return Environment.class; case f: return Feed.class; case m: return Metric.class; case mt: return MetricType.class; case r: return Resource.class; case rt: return ResourceType.class; // case rl: // return Relationship.class; case d: return DataEntity.class; case ot: return OperationType.class; case mp: return MetadataPack.class; default: throw new IllegalStateException("There is no " + Entity.class.getName() + " type for " + segmentType.getClass().getName() + " '" + segmentType.name() + "'"); } }
TraversalContext<BE, E> proceedTo(Path path) { if (!AbstractElement.segmentTypeFromType(entityClass).equals(path.getSegment().getElementType())) { throw new IllegalArgumentException("Path doesn't point to the type of element currently being accessed."); } return replacePath(Util.extendTo(this, path)); }
public <E extends AbstractElement, B extends Blueprint> ElementTypes<E, B> byElement(Class<E> elementType) { for(SegmentType st : SegmentType.values()) { ElementTypes ret = elementTypes.get(st); if (ret.getElementType().equals(elementType)) { return ret; } } throw new IllegalArgumentException("Unknown element type: " + elementType); } }
public RelationNotFoundException(SegmentType sourceEntityType, String nameOrId, Filter[] filters, String message, Throwable cause) { this(sourceEntityType == null ? null : sourceEntityType.getSimpleName(), nameOrId, oneElem(filters), message, cause); }
default: throw new IllegalStateException("There is no " + Entity.class.getName() + " type for " + elementType.getClass().getName() + " '" + elementType.name() + "'");
if (!SegmentType.r.equals(p.getSegment().getElementType())) { throw new IllegalArgumentException("Descend can only traverse child resources.");
public <B extends Blueprint> ElementTypes<? extends AbstractElement<B, ?>, B, ?> byBlueprint(Class<B> blueprintType) { for(SegmentType st : SegmentType.values()) { ElementTypes ret = elementTypes.get(st); if (ret.getBlueprintType().equals(blueprintType)) { return ret; } } throw new IllegalArgumentException("Unknown blueprint type: " + blueprintType); }
protected void checkPathLegal(Path targetPath) { if (!context.entityClass.getSimpleName().equals(targetPath.getSegment().getElementType().getSimpleName())) { throw new IllegalArgumentException("Current position in the inventory traversal expects entities of type " + context.entityClass.getSimpleName() + " which is incompatible with the provided path: " + targetPath); } }