@Test public void testAddSlug$new() throws Exception { Slug slug = this.container.addSlug("slug"); assertThat(slug,notNullValue()); assertThat(this.container.findSlug("slug"),sameInstance(slug)); }
@Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); }
InMemoryContainer extends InMemoryResource implements Container { @Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); } }
InMemoryContainer extends InMemoryResource implements Container { @Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); } InMemoryContainer(ResourceId id, ResourceId parentId);   InMemoryContainer(ResourceId id); }
InMemoryContainer extends InMemoryResource implements Container { @Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); } InMemoryContainer(ResourceId id, ResourceId parentId);   InMemoryContainer(ResourceId id); @Override void accept(ResourceVisitor visitor); @Override Resource addMember(ResourceId resourceId); @Override boolean hasMember(ResourceId resource); @Override Set<Member> members(); @Override Member findMember(ResourceId resourceId); @Override boolean removeMember(Member member); @Override Set<Slug> slugs(); @Override Slug findSlug(String preferredPath); @Override Slug addSlug(String preferredPath); @Override String toString(); }
InMemoryContainer extends InMemoryResource implements Container { @Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); } InMemoryContainer(ResourceId id, ResourceId parentId);   InMemoryContainer(ResourceId id); @Override void accept(ResourceVisitor visitor); @Override Resource addMember(ResourceId resourceId); @Override boolean hasMember(ResourceId resource); @Override Set<Member> members(); @Override Member findMember(ResourceId resourceId); @Override boolean removeMember(Member member); @Override Set<Slug> slugs(); @Override Slug findSlug(String preferredPath); @Override Slug addSlug(String preferredPath); @Override String toString();  }