BandMathsMaskPersistableSpi implements DimapPersistableSpi { @Override public boolean canDecode(Element element) { final String type = element.getAttributeValue(DimapProductConstants.ATTRIB_TYPE); return Mask.BandMathsType.TYPE_NAME.equals(type); }  @Override boolean canDecode(Element element); @Override boolean canPersist(Object object); @Override DimapPersistable createPersistable();  }
@Test public void canDecodeIntendedElement() { final Element element = new Element(DimapProductConstants.TAG_MASK); element.setAttribute(DimapProductConstants.ATTRIB_TYPE, "Maths"); assertTrue(persistableSpi.canDecode(element)); assertTrue(DimapPersistence.getPersistable(element) instanceof BandMathsMaskPersistable); }
@Test public void cannotDecodeOtherElement() { final Element element = new Element(DimapProductConstants.TAG_MASK); element.setAttribute(DimapProductConstants.ATTRIB_TYPE, "Other"); assertFalse(persistableSpi.canDecode(element)); assertFalse(DimapPersistence.getPersistable(element) instanceof BandMathsMaskPersistable); }