@Override public boolean isMatching(CubeId other) { return equals(other); }
@Override public Cube<?> getCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); for (Map.Entry<CubeId, Cube<?>> cubeEntry : this.cubes.entrySet()) { CubeId internalCubeId = cubeEntry.getKey(); if (internalCubeId.isMatching(cubeId)) { return cubeEntry.getValue(); } } return null; }
public void register(@Observes(precedence = 100) CubeConfiguration configuration, Injector injector) { CubeRegistry registry = new LocalCubeRegistry(); registryProducer.set(registry); } }
public CubeId create(String id) { Objects.requireNonNull(id, "Id must not be null."); final CubeId cubeId; if (id.matches(StarredCubeId.PATTERN)) { cubeId = new StarredCubeId(id); } else if (id.matches(ParallelizedCubeId.PATTERN)) { cubeId = new ParallelizedCubeId(id); } else { cubeId = new DefaultCubeId(id); } return cubeId; } }
@Override public boolean isMatching(CubeId other) { if (other instanceof ParallelizedCubeId) { return equals(other); } if (other instanceof StarredCubeId) { String otherId = other.getId(); String otherStarlessId = otherId.substring(0, otherId.length() - 1); String uuidLessId = id.substring(0, id.lastIndexOf('_')); return uuidLessId.equals(otherStarlessId); } return false; }
@Override public <T extends Cube<?>> T getCube(String id, Class<T> type) { return type.cast(getCube(id)); }
@Test(expected = IllegalArgumentException.class) public void shouldNotBeAbleToAddCubeByStarredCubeId() throws Exception { // given: String cubeId = "tomcat*"; Cube cube = createCubeMock(cubeId); // when: cubeRegistry.addCube(cube); }
public void register(@Observes(precedence = 100) CubeConfiguration configuration, Injector injector) { CubeRegistry registry = new LocalCubeRegistry(); registryProducer.set(registry); } }
@Override public Cube<?> getCube(String id) { CubeId cubeId = CubeIdFactory.get().create(id); for (Map.Entry<CubeId, Cube<?>> cubeEntry : this.cubes.entrySet()) { CubeId internalCubeId = cubeEntry.getKey(); if (internalCubeId.isMatching(cubeId)) { return cubeEntry.getValue(); } } return null; }
public CubeId create(String id) { Objects.requireNonNull(id, "Id must not be null."); final CubeId cubeId; if (id.matches(StarredCubeId.PATTERN)) { cubeId = new StarredCubeId(id); } else if (id.matches(ParallelizedCubeId.PATTERN)) { cubeId = new ParallelizedCubeId(id); } else { cubeId = new DefaultCubeId(id); } return cubeId; } }
@Override public boolean isMatching(CubeId other) { if (other instanceof ParallelizedCubeId) { return equals(other); } if (other instanceof StarredCubeId) { String otherId = other.getId(); String otherStarlessId = otherId.substring(0, otherId.length() - 1); String uuidLessId = id.substring(0, id.lastIndexOf('_')); return uuidLessId.equals(otherStarlessId); } return false; }
@Override public boolean isMatching(CubeId other) { return equals(other); }
@Override public <T extends Cube<?>> T getCube(String id, Class<T> type) { return type.cast(getCube(id)); }
@Before public void setUp() throws Exception { cubeRegistry = new LocalCubeRegistry(); }