@Test(expected = NullPointerException.class) public void shouldNotAllowNullPartialSurface() { rootValidator.isValid(Mockito.mock(Root.class), null); }
public boolean isValid(Root root, TurkishSequence partialSurface) { Validate.notNull(root, "Root to validate cannot be null."); Validate.notNull(partialSurface, "Partial surface for the root cannot be null"); final TurkishSequence rootSequence = root.getSequence(); if (rootSequence.length() > partialSurface.length()) return false; if (root.getLexeme().getAttributes().contains(LexemeAttribute.CompoundP3sg)) return true; return partialSurface.startsWith(rootSequence) || partialSurface.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE).startsWith(rootSequence.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE)); }
RootValidator { public boolean isValid(Root root, TurkishSequence partialSurface) { Validate.notNull(root, "Root to validate cannot be null."); Validate.notNull(partialSurface, "Partial surface for the root cannot be null"); final TurkishSequence rootSequence = root.getSequence(); if (rootSequence.length() > partialSurface.length()) return false; if (root.getLexeme().getAttributes().contains(LexemeAttribute.CompoundP3sg)) return true; return partialSurface.startsWith(rootSequence) || partialSurface.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE).startsWith(rootSequence.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE)); } }
RootValidator { public boolean isValid(Root root, TurkishSequence partialSurface) { Validate.notNull(root, "Root to validate cannot be null."); Validate.notNull(partialSurface, "Partial surface for the root cannot be null"); final TurkishSequence rootSequence = root.getSequence(); if (rootSequence.length() > partialSurface.length()) return false; if (root.getLexeme().getAttributes().contains(LexemeAttribute.CompoundP3sg)) return true; return partialSurface.startsWith(rootSequence) || partialSurface.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE).startsWith(rootSequence.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE)); }  }
RootValidator { public boolean isValid(Root root, TurkishSequence partialSurface) { Validate.notNull(root, "Root to validate cannot be null."); Validate.notNull(partialSurface, "Partial surface for the root cannot be null"); final TurkishSequence rootSequence = root.getSequence(); if (rootSequence.length() > partialSurface.length()) return false; if (root.getLexeme().getAttributes().contains(LexemeAttribute.CompoundP3sg)) return true; return partialSurface.startsWith(rootSequence) || partialSurface.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE).startsWith(rootSequence.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE)); }  boolean isValid(Root root, TurkishSequence partialSurface); }
RootValidator { public boolean isValid(Root root, TurkishSequence partialSurface) { Validate.notNull(root, "Root to validate cannot be null."); Validate.notNull(partialSurface, "Partial surface for the root cannot be null"); final TurkishSequence rootSequence = root.getSequence(); if (rootSequence.length() > partialSurface.length()) return false; if (root.getLexeme().getAttributes().contains(LexemeAttribute.CompoundP3sg)) return true; return partialSurface.startsWith(rootSequence) || partialSurface.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE).startsWith(rootSequence.getUnderlyingString().toLowerCase(Constants.TURKISH_LOCALE)); }  boolean isValid(Root root, TurkishSequence partialSurface);  }