org.compass.core.mapping.osem.builder
Class SearchablePropertyMappingBuilder

java.lang.Object
  extended by org.compass.core.mapping.osem.builder.SearchablePropertyMappingBuilder

public class SearchablePropertyMappingBuilder
extends Object

Specifies a searchable property on property or field of SearchableMappingBuilder.

In order to make the property searchable, at least one SearchableMetaDataMappingBuilder must be added to it using add(SearchableMetaDataMappingBuilder). If no meta data are added to the searchable property, a managed id will be created for it (automatically, by default, can be controlled using managedId(org.compass.core.mapping.osem.ManagedId)).

The searchable property/meta-data is meant to handle basic types (which usually translate to a String saved in the search engine). The conversion is done using converters which can be set on the SearchableMetaDataMappingBuilder. The managed id converter can also be controlled using one of the managedIdConverter method.

Note, that most of the time, a specialized converter for user classes will not be needed, since the SearchableComponentMappingBuilder usually makes more sense to use.

The searchable property can annotate an array/collections as well, with the array element type used for Converter lookups.

Author:
kimchy
See Also:
OSEM.property(String), SearchableMappingBuilder.add(SearchablePropertyMappingBuilder)

Field Summary
(package private)  ClassPropertyMapping mapping
           
 
Constructor Summary
SearchablePropertyMappingBuilder(String name)
          Constructs a new searchable property mapping builder based on the property/field name.
 
Method Summary
 SearchablePropertyMappingBuilder accessor(Accessor accessor)
          Sets the acessor the will be used for the class property.
 SearchablePropertyMappingBuilder accessor(String accessor)
          Sets the acessor the will be used for the class property.
 SearchablePropertyMappingBuilder add(SearchableMetaDataMappingBuilder builder)
          Adds an optional meta data mapping.
 SearchablePropertyMappingBuilder managedId(ManagedId managedId)
          Sets the managed id for the mapping.
 SearchablePropertyMappingBuilder managedIdConverter(Converter managedIdConverter)
          Sets the converter that will be used when converting the managed id.
 SearchablePropertyMappingBuilder managedIdConverter(ResourcePropertyConverter converter)
          Sets the converter that will be used when converting the managed id.
 SearchablePropertyMappingBuilder managedIdConverter(String converterName)
          Sets the converter lookup name that will be used when converting the managed id.
 SearchablePropertyMappingBuilder managedIdIndex(Property.Index index)
          Sets the index of the managed id (if it is created).
 SearchablePropertyMappingBuilder mappingConverter(Converter mappingConverter)
          Sets the mapping converter.
 SearchablePropertyMappingBuilder mappingConverter(String mappingConverter)
          Sets the mapping converter lookup name.
 SearchablePropertyMappingBuilder overrideByName(boolean override)
          Sets if this mapping will override another mapping with the same name.
 SearchablePropertyMappingBuilder type(Class type)
          The class type of the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapping

final ClassPropertyMapping mapping
Constructor Detail

SearchablePropertyMappingBuilder

public SearchablePropertyMappingBuilder(String name)
Constructs a new searchable property mapping builder based on the property/field name.

Method Detail

accessor

public SearchablePropertyMappingBuilder accessor(Accessor accessor)
Sets the acessor the will be used for the class property. Defaults to property (getter and optionally setter).


accessor

public SearchablePropertyMappingBuilder accessor(String accessor)
Sets the acessor the will be used for the class property. Defaults to property (getter and optionally setter). Note, this is the lookup name of a PropertyAccessor registered with Compass, with two default ones (custom ones can be easily added) named field and property.


managedId

public SearchablePropertyMappingBuilder managedId(ManagedId managedId)
Sets the managed id for the mapping. Managed id controls Compass (optionally) created managed id (mainly used when unmarshalling, when it is set to true). Defaults to the global setting CompassEnvironment.Osem.MANAGED_ID_DEFAULT which in turn defaults to ManagedId.NO_STORE.


managedIdIndex

public SearchablePropertyMappingBuilder managedIdIndex(Property.Index index)
Sets the index of the managed id (if it is created). Defaults to the global setting CompassEnvironment.Osem.MANAGED_ID_INDEX


managedIdConverter

public SearchablePropertyMappingBuilder managedIdConverter(String converterName)
Sets the converter lookup name that will be used when converting the managed id. Note, if there is a single meta-data mapping, and it has a special converter set for it, then the managed id converter will be automatically set to it.


managedIdConverter

public SearchablePropertyMappingBuilder managedIdConverter(Converter managedIdConverter)
Sets the converter that will be used when converting the managed id. Note, if there is a single meta-data mapping, and it has a special converter set for it, then the managed id converter will be automatically set to it.


managedIdConverter

public SearchablePropertyMappingBuilder managedIdConverter(ResourcePropertyConverter converter)
Sets the converter that will be used when converting the managed id. Note, if there is a single meta-data mapping, and it has a special converter set for it, then the managed id converter will be automatically set to it.


overrideByName

public SearchablePropertyMappingBuilder overrideByName(boolean override)
Sets if this mapping will override another mapping with the same name. Defaults to true.


mappingConverter

public SearchablePropertyMappingBuilder mappingConverter(String mappingConverter)
Sets the mapping converter lookup name. Defaults to ClassPropertyMappingConverter.


mappingConverter

public SearchablePropertyMappingBuilder mappingConverter(Converter mappingConverter)
Sets the mapping converter. Defaults to ClassPropertyMappingConverter.


type

public SearchablePropertyMappingBuilder type(Class type)
The class type of the property. Mainly used for Collection properties, without specific Generic type parameter.


add

public SearchablePropertyMappingBuilder add(SearchableMetaDataMappingBuilder builder)
Adds an optional meta data mapping.



Copyright (c) 2004-2009 The Compass Project.