/** * @return Parent of the resource, if any. Throws IllegalStateException if it's the root-level resource. */ public IResource getParent() { switch (level) { case KEYSPACE: return root(); case FUNCTION: return keyspace(keyspace); } throw new IllegalStateException("Root-level resource can't have a parent"); }
/** * @return Parent of the resource, if any. Throws IllegalStateException if it's the root-level resource. */ public IResource getParent() { switch (level) { case KEYSPACE: return root(); case FUNCTION: return keyspace(keyspace); } throw new IllegalStateException("Root-level resource can't have a parent"); }
/** * @return Parent of the resource, if any. Throws IllegalStateException if it's the root-level resource. */ public IResource getParent() { switch (level) { case KEYSPACE: return root(); case FUNCTION: return keyspace(keyspace); } throw new IllegalStateException("Root-level resource can't have a parent"); }
/** * Parses a resource name into a FunctionResource instance. * * @param name Name of the function resource. * @return FunctionResource instance matching the name. */ public static FunctionResource fromName(String name) { String[] parts = StringUtils.split(name, '/'); if (!parts[0].equals(ROOT_NAME) || parts.length > 3) throw new IllegalArgumentException(String.format("%s is not a valid function resource name", name)); if (parts.length == 1) return root(); if (parts.length == 2) return keyspace(parts[1]); String[] nameAndArgs = StringUtils.split(parts[2], "[|]"); return function(parts[1], nameAndArgs[0], argsListFromString(nameAndArgs[1])); }
/** * Parses a resource name into a FunctionResource instance. * * @param name Name of the function resource. * @return FunctionResource instance matching the name. */ public static FunctionResource fromName(String name) { String[] parts = StringUtils.split(name, '/'); if (!parts[0].equals(ROOT_NAME) || parts.length > 3) throw new IllegalArgumentException(String.format("%s is not a valid function resource name", name)); if (parts.length == 1) return root(); if (parts.length == 2) return keyspace(parts[1]); String[] nameAndArgs = StringUtils.split(parts[2], "[|]"); return function(parts[1], nameAndArgs[0], argsListFromString(nameAndArgs[1])); }
/** * Parses a resource name into a FunctionResource instance. * * @param name Name of the function resource. * @return FunctionResource instance matching the name. */ public static FunctionResource fromName(String name) { String[] parts = StringUtils.split(name, '/'); if (!parts[0].equals(ROOT_NAME) || parts.length > 3) throw new IllegalArgumentException(String.format("%s is not a valid function resource name", name)); if (parts.length == 1) return root(); if (parts.length == 2) return keyspace(parts[1]); String[] nameAndArgs = StringUtils.split(parts[2], "[|]"); return function(parts[1], nameAndArgs[0], argsListFromString(nameAndArgs[1])); }
/** * Creates an IResource instance from its external name. * Resource implementation class is inferred by matching against the known IResource * impls' root level resources. * @param name * @return an IResource instance created from the name */ public static IResource fromName(String name) { if (name.startsWith(RoleResource.root().getName())) return RoleResource.fromName(name); else if (name.startsWith(DataResource.root().getName())) return DataResource.fromName(name); else if (name.startsWith(FunctionResource.root().getName())) return FunctionResource.fromName(name); else if (name.startsWith(JMXResource.root().getName())) return JMXResource.fromName(name); else throw new IllegalArgumentException(String.format("Name %s is not valid for any resource type", name)); }
/** * Creates an IResource instance from its external name. * Resource implementation class is inferred by matching against the known IResource * impls' root level resources. * @param name * @return an IResource instance created from the name */ public static IResource fromName(String name) { if (name.startsWith(RoleResource.root().getName())) return RoleResource.fromName(name); else if (name.startsWith(DataResource.root().getName())) return DataResource.fromName(name); else if (name.startsWith(FunctionResource.root().getName())) return FunctionResource.fromName(name); else if (name.startsWith(JMXResource.root().getName())) return JMXResource.fromName(name); else throw new IllegalArgumentException(String.format("Name %s is not valid for any resource type", name)); }
/** * Creates an IResource instance from its external name. * Resource implementation class is inferred by matching against the known IResource * impls' root level resources. * @param name * @return an IResource instance created from the name */ public static IResource fromName(String name) { if (name.startsWith(RoleResource.root().getName())) return RoleResource.fromName(name); else if (name.startsWith(DataResource.root().getName())) return DataResource.fromName(name); else if (name.startsWith(FunctionResource.root().getName())) return FunctionResource.fromName(name); else if (name.startsWith(JMXResource.root().getName())) return JMXResource.fromName(name); else throw new IllegalArgumentException(String.format("Name %s is not valid for any resource type", name)); }
res = FunctionResource.root();
res = FunctionResource.root();
res = FunctionResource.root();