Encoder { @Nullable public UnitBitSet encode(@NotNull CharSequence letters, boolean force) { if (UnitBitSet.MAX_CHARS_IN_WORD <= letters.length() + offset) return null; int unknownLetters = 0; byte[] indices = new byte[letters.length()]; for (int i = 0; i < letters.length(); i++) { char letter = letters.charAt(i); int index = alphabet.getIndex(letter, force); if (index < 0) { unknownLetters++; } else { indices[i] = (byte)index; } } if (unknownLetters == letters.length()) return WORD_OF_ENTIRELY_UNKNOWN_LETTERS; if (unknownLetters>0) return null; return new UnitBitSet(indices, alphabet); } Encoder();  Encoder(@NotNull Alphabet alphabet); Alphabet getAlphabet(); @Nullable UnitBitSet encode(@NotNull CharSequence letters, boolean force); @NotNull String decode(@NotNull byte[] compressed); int getFirstLetterIndex(byte firstPackedByte);  }
@Test public void testUnknown() { Encoder encoder = new Encoder(new Alphabet("abc")); final String wordToTest1 = "def"; final UnitBitSet bitSet = encoder.encode(wordToTest1, true); assertEquals(bitSet, Encoder.WORD_OF_ENTIRELY_UNKNOWN_LETTERS); }