SegmentRegistry { public static void register( final int type, @NotNull final SegmentReader reader) { final SegmentReader previous = readers.putIfAbsent(type, reader); if (previous != null) { throw new IllegalArgumentException( "Duplicate segment readers with type " + type); } } private  SegmentRegistry(); static void register(
            final int type,
            @NotNull
            final SegmentReader reader); @NotNull static Segment read(
            final int type,
            @NotNull
            final Buffer buffer);  }
@Test public void register() { final int ID = -1; SegmentRegistry.register(ID, DUMMY); }
@Test(expected = IllegalArgumentException.class) public void registerExisting() { final int ID = -3; SegmentRegistry.register(ID, DUMMY); SegmentRegistry.register(ID, DUMMY); }