BandMathsMaskPersistableSpi implements DimapPersistableSpi { @Override public boolean canPersist(Object object) { if (object instanceof Mask) { Mask mask = (Mask) object; if(mask.getImageType() == Mask.BandMathsType.INSTANCE) { return true; } } return false; }  @Override boolean canDecode(Element element); @Override boolean canPersist(Object object); @Override DimapPersistable createPersistable();  }
@Test public void canPersistIntendedMaskType() { final Mask mask = new Mask("M", 10, 10, Mask.BandMathsType.INSTANCE); assertTrue(persistableSpi.canPersist(mask)); assertTrue(DimapPersistence.getPersistable(mask) instanceof BandMathsMaskPersistable); }
@Test public void cannotPersistOtherMaskType() { final Mask mask = new Mask("M", 10, 10, new Mask.ImageType("Other") { @Override public MultiLevelImage createImage(Mask mask) { return null; } }); assertFalse(persistableSpi.canPersist(mask)); assertFalse(DimapPersistence.getPersistable(mask) instanceof BandMathsMaskPersistable); }