D - The data type of this resource type.
Supported Types include: String, Long, Double, and Booleanpublic interface ResourceType<D> extends Type
An ontological element which models and categorises the various Resource in the graph.
This ontological element behaves similarly to Type when defining how it relates to other
types. It has two additional functions to be aware of:
1. It has a ResourceType.DataType constraining the data types of the values it's instances may take.
2. Any of it's instances are unique to the type.
For example if you have a ResourceType modelling month throughout the year there can only be one January.
| Modifier and Type | Interface and Description |
|---|---|
static class |
ResourceType.DataType<D>
A class used to hold the supported data types of resources and any other concepts.
|
| Modifier and Type | Method and Description |
|---|---|
ResourceType<D> |
deletePlaysRole(RoleType roleType)
Removes the RoleType to prevent instances of this ResourceType from playing it.
|
ResourceType.DataType<D> |
getDataType()
Get the data type to which instances of the ResourceType must conform.
|
String |
getRegex()
Retrieve the regular expression to which instances of this ResourceType must conform, or
null if no
regular expression is set. |
<V> Resource<V> |
getResource(V value)
Get the Resource with the value provided, and its type, or return NULL
|
Collection<Resource<D>> |
instances()
Returns a collection of all Resource Instances of this ResourceType.
|
Boolean |
isUnique()
Returns whether the ResourceType is unique.
|
ResourceType<D> |
playsRole(RoleType roleType)
Sets the RoleType which instances of this ResourceType may play.
|
Resource<D> |
putResource(D value)
Set the value for the Resource, unique to its type.
|
ResourceType<D> |
setAbstract(Boolean isAbstract)
Sets the ResourceType to be abstract - which prevents it from having any instances.
|
ResourceType<D> |
setRegex(String regex)
Set the regular expression that instances of the ResourceType must conform to.
|
ResourceType<D> |
subType(ResourceType<D> type)
Adds another subtype to this type
|
Collection<ResourceType<D>> |
subTypes()
Returns a collection of subtypes of this ResourceType.
|
ResourceType<D> |
superType()
Returns the supertype of this ResourceType.
|
ResourceType<D> |
superType(ResourceType<D> type)
Sets the supertype of the ResourceType to be the ResourceType specified.
|
getName, getRulesOfConclusion, getRulesOfHypothesis, hasResource, isAbstract, isImplicit, key, playsRolesasEntity, asEntityType, asInstance, asRelation, asRelationType, asResource, asResourceType, asRoleType, asRule, asRuleType, asType, delete, getId, isEntity, isEntityType, isInstance, isRelation, isRelationType, isResource, isResourceType, isRoleType, isRule, isRuleType, isTypecompareToResourceType<D> setAbstract(Boolean isAbstract)
setAbstract in interface TypeisAbstract - Specifies if the ResourceType is to be abstract (true) or not (false).ResourceType<D> superType(ResourceType<D> type)
type - The super type of this ResourceType.ResourceType<D> subType(ResourceType<D> type)
type - The sub type of this resource typeResourceType<D> playsRole(RoleType roleType)
ResourceType<D> deletePlaysRole(RoleType roleType)
deletePlaysRole in interface TyperoleType - The Role Type which the instances of this ResourceType should no longer be allowed to play.ResourceType<D> setRegex(String regex)
regex - The regular expression that instances of this ResourceType must conform to.Resource<D> putResource(D value)
value - A value for the Resource which is unique to its typeResourceType<D> superType()
<V> Resource<V> getResource(V value)
V - The data type of the value. Supported types include: String, Long, Double, and Boolean.value - A value which a Resource in the graph may be holdingResourceCollection<ResourceType<D>> subTypes()
Collection<Resource<D>> instances()
ResourceType.DataType<D> getDataType()
String getRegex()
null if no
regular expression is set.
By default, a ResourceType does not have a regular expression set.Boolean isUnique()
Copyright © 2017 Grakn Labs Ltd. All rights reserved.