• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Identifiable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.hateoas.Identifiable的典型用法代码示例。如果您正苦于以下问题:Java Identifiable类的具体用法?Java Identifiable怎么用?Java Identifiable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Identifiable类属于org.springframework.hateoas包,在下文中一共展示了Identifiable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: IdentifiableToIdConverter

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
/**
 * Creates a new ToAttributedValueConverter instance.
 * 
 * @param mapper the mapper in use
 * @param reflectionProvider the reflection provider in use
 * @param lookup the converter lookup in use
 * @param valueFieldName the field defining the tag's value (may be null)
 * @param valueDefinedIn the type defining the field
 */
public IdentifiableToIdConverter(
    final Class<Identifiable<?>> type, final Mapper mapper, final ReflectionProvider reflectionProvider,
    final ConverterLookup lookup, final String valueFieldName, Class<?> valueDefinedIn) {
    this.type = type;

       Field field = null;
       try {
           field = (valueDefinedIn != null ? valueDefinedIn : type.getSuperclass())
               .getDeclaredField("id");
          
           if (!field.isAccessible()) {
               field.setAccessible(true);
           }
       } catch (NoSuchFieldException e) {
           throw new IllegalArgumentException(e.getMessage() + ": " + valueFieldName);
       }
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:27,代码来源:IdentifiableToIdConverter.java


示例2: slash

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
public T slash(Object object) {

		if (object == null) {
			return getThis();
		}

		if (object instanceof Identifiable) {
			return slash((Identifiable<?>) object);
		}

		String path = object.toString();

		if (path.endsWith("#")) {
			path = path.substring(0, path.length() - 1);
		}

		if (!StringUtils.hasText(path)) {
			return getThis();
		}

		String uriString = uriComponents.toUriString();
		UriComponentsBuilder builder = uriString.isEmpty() ? fromUri(uriComponents.toUri())
				: fromUriString(uriString);

		UriComponents components = UriComponentsBuilder.fromUriString(path).build();

		for (String pathSegment : components.getPathSegments()) {
			builder.pathSegment(pathSegment);
		}

		String fragment = components.getFragment();
		if (StringUtils.hasText(fragment)) {
			builder.fragment(fragment);
		}

		return createNewInstance(builder.query(components.getQuery()));
	}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:38,代码来源:LinkBuilderSupport.java


示例3: slash

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
@Override
public AffordanceBuilder slash(Identifiable<?> identifiable) {
    if (identifiable == null) {
        return this;
    }

    return slash(identifiable.getId());
}
 
开发者ID:dschulten,项目名称:hydra-java,代码行数:9,代码来源:AffordanceBuilder.java


示例4: toFriendlyId

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
public static String toFriendlyId(Identifiable<UUID> entity) {
	return Url62.encode(entity.getId());
}
 
开发者ID:Devskiller,项目名称:friendly-id,代码行数:4,代码来源:UuidHelper.java


示例5: linkToSingleResource

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
@Override
public Link linkToSingleResource(Identifiable<?> entity) {
	Assert.notNull(entity);
	return linkToSingleResource(entity.getClass(), entity.getId());
}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:6,代码来源:AbstractEntityLinks.java


示例6: linkForSingleResource

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
@Override
public LinkBuilder linkForSingleResource(Identifiable<?> entity) {
	Assert.notNull(entity);
	return linkForSingleResource(entity.getClass(), entity.getId());
}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:6,代码来源:AbstractEntityLinks.java


示例7: convertAnnotationToBrat

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
/**
 * Converts a DiscourseDB annotation into Brat annotations.
 * A single DiscourseDB annotation might result in multiple Brat annotations 
 * 
 * @param dbAnno the DiscourseDB annotation to convert
 * @param spanOffset the current offset of the Contribution or Content within the aggregate document
 * @param text the contribution text
 * @param entity the annotated entity (Contribution or Content)
 * @param annotationVersionInfo a list in which version information about the exported annotations will be stored 
 * @return a list of BratAnnotations 
 */
@Transactional(propagation= Propagation.REQUIRED, readOnly=true)
private <T extends BaseEntity & Identifiable<Long>> List<BratAnnotation> convertAnnotationToBrat(AnnotationInstance dbAnno, int spanOffset, String sep, String text, T entity, BratIdGenerator bratIdGenerator) {
	Assert.notNull(dbAnno, "The annotation instance to be converted cannot be null.");
	Assert.notNull(text, "The text may be empty, but not null.");
	Assert.notNull(entity, "The entity associated with the annotation cannot be null.");
	Assert.notNull(bratIdGenerator, "The Brat IDGenerator cannot be null.");
	
	//one DiscourseDB annotation could result in multiple BRAT annotations 
	List<BratAnnotation> newAnnotations = new ArrayList<>();
	
	//PRODUCE Text-Bound Annotation for ALL other annotations		
	BratAnnotation textBoundAnnotation = new BratAnnotation();
	textBoundAnnotation.setType(BratAnnotationType.BRAT_TEXT);			
	textBoundAnnotation.setId(bratIdGenerator.getNextAvailableBratId(BratAnnotationType.BRAT_TEXT, dbAnno.getId()));
	textBoundAnnotation.setAnnotationLabel(dbAnno.getType());

	//CALC OFFSET			
	if (entity instanceof Contribution) {
		//annotations on contributions are always annotated on the contribution separator as an entity label 
		textBoundAnnotation.setBeginIndex(spanOffset);
		textBoundAnnotation.setEndIndex(spanOffset+ sep.length());
		textBoundAnnotation.setCoveredText(sep);															
	}else if (entity instanceof Content) {
		//content labels are always annotated as text spans on the currentRevision content entity
		if(dbAnno.getEndOffset()==0){
			log.warn("Labels on Content entites should define a span and should not be entity labels."); 
		}
		textBoundAnnotation.setBeginIndex(spanOffset+dbAnno.getBeginOffset()+sep.length()+1);
		textBoundAnnotation.setEndIndex(spanOffset+dbAnno.getEndOffset()+sep.length()+1);
		textBoundAnnotation.setCoveredText(text.substring(dbAnno.getBeginOffset(),dbAnno.getEndOffset()));											
	}		
	textBoundAnnotation.setVersionInfo(new VersionInfo(AnnotationSourceType.DDB_ANNOTATION, textBoundAnnotation.getId(), dbAnno.getId(), dbAnno.getEntityVersion()));
	newAnnotations.add(textBoundAnnotation);
	
	//FEATURE VALUES ARE USED TO CREATE BRAT ANNOTATION ATTRIBUTES. Feature types are ignored.
	for(Feature f:dbAnno.getFeatures()){			
		BratAnnotation newAttribute = new BratAnnotation();
		newAttribute.setType(BratAnnotationType.BRAT_NOTE);			
		newAttribute.setId(bratIdGenerator.getNextAvailableBratId(BratAnnotationType.BRAT_NOTE, f.getId()));
		newAttribute.setAnnotationLabel("AnnotatorNotes");
		newAttribute.setNoteText(f.getValue());
		newAttribute.setSourceAnnotationId(textBoundAnnotation.getId());
		newAttribute.setVersionInfo(new VersionInfo(AnnotationSourceType.DDB_FEATURE, newAttribute.getId(), f.getId(), f.getEntityVersion()));
		newAnnotations.add(newAttribute);				
	}
   	
	return newAnnotations;
}
 
开发者ID:DiscourseDB,项目名称:discoursedb-core,代码行数:60,代码来源:BratService.java


示例8: marshal

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
public void marshal(final Object source, final HierarchicalStreamWriter writer,
    final MarshallingContext context) {
    if(source instanceof Identifiable){
    	writer.setValue(((Identifiable<?>)source).getId().toString());
    }
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:7,代码来源:IdentifiableToIdConverter.java


示例9: serialize

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
@Override
public void serialize(Identifiable<?> value, JsonGenerator jgen, SerializerProvider provider) 
  throws IOException, JsonProcessingException {
	provider.defaultSerializeValue(value.getId(), jgen);
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:6,代码来源:IdentifiableSerializer.java


示例10: addSelfUpdateLink

import org.springframework.hateoas.Identifiable; //导入依赖的package包/类
public void addSelfUpdateLink(Collection<Link> links, Identifiable<?> identifiable){
    Link singleResourceLink = repositoryEntityLinks.linkToSingleResource(identifiable).expand();

    Assert.notNull(singleResourceLink);

    Link updateLink = singleResourceLink.withRel( "self" + UPDATE_REL_SUFFIX );

    links.add(updateLink);

    Link deleteLink = singleResourceLink.withRel( "self" + DELETE_REL_SUFFIX );

    links.add(deleteLink);
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:14,代码来源:LinkHelper.java



注:本文中的org.springframework.hateoas.Identifiable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Tweet类代码示例发布时间:2022-05-21
下一篇:
Java LocalTransaction类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap