@Override public void remove() { if (index == WHOLE_COLLECTION) { setValue(null); } else if (isCollection()) { Object o = getBaseValue(); Object collection = ValueUtils.remove(getBaseValue(), index); if (collection != o) { ValueUtils.setValue(getBean(), getPropertyDescriptor(), collection); } } else if (index == 0) { index = WHOLE_COLLECTION; setValue(null); } }
@Override public void remove() { if (index == WHOLE_COLLECTION) { setValue(null); } else if (isCollection()) { Object o = getBaseValue(); Object collection = ValueUtils.remove(getBaseValue(), index); if (collection != o) { ValueUtils.setValue(getBean(), getPropertyDescriptor(), collection); } } else if (index == 0) { index = WHOLE_COLLECTION; setValue(null); } }
/** * If the property contains a collection, then the length of that * collection, otherwise - 1. * @return int length */ @Override public int getLength() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return 1; } if( pd.isMany() ) { return ((List<?>)getBean().eGet(pd)).size(); } // if (pd instanceof IndexedPropertyDescriptor) { // return ValueUtils.getIndexedPropertyLength( // getBean(), // (IndexedPropertyDescriptor) pd); // } // // int hint = ValueUtils.getCollectionHint(pd.getPropertyType()); // if (hint == -1) { // return 1; // } return ValueUtils.getLength(getBaseValue()); }
/** * If the property contains a collection, then the length of that * collection, otherwise - 1. * @return int length */ @Override public int getLength() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return 1; } if( pd.isMany() ) { return ((List<?>)getBean().eGet(pd)).size(); } // if (pd instanceof IndexedPropertyDescriptor) { // return ValueUtils.getIndexedPropertyLength( // getBean(), // (IndexedPropertyDescriptor) pd); // } // // int hint = ValueUtils.getCollectionHint(pd.getPropertyType()); // if (hint == -1) { // return 1; // } return ValueUtils.getLength(getBaseValue()); }
/** * If index == WHOLE_COLLECTION, the value of the property, otherwise * the value of the index'th element of the collection represented by the * property. If the property is not a collection, index should be zero * and the value will be the property itself. * @return Object */ @Override public Object getImmediateNode() { if (value == UNINITIALIZED) { if (index == WHOLE_COLLECTION) { value = ValueUtils.getValue(getBaseValue()); } else { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { value = null; } else { value = ValueUtils.getValue(getBean(), pd, index); } } } return value; }
/** * If index == WHOLE_COLLECTION, the value of the property, otherwise * the value of the index'th element of the collection represented by the * property. If the property is not a collection, index should be zero * and the value will be the property itself. * @return Object */ @Override public Object getImmediateNode() { if (value == UNINITIALIZED) { if (index == WHOLE_COLLECTION) { value = ValueUtils.getValue(getBaseValue()); } else { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { value = null; } else { value = ValueUtils.getValue(getBean(), pd, index); } } } return value; }
@Override public boolean isCollection() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return false; } if( pd.isMany() ) { return true; } // if (pd instanceof IndexedPropertyDescriptor) { // return true; // } // int hint = ValueUtils.getCollectionHint(pd.getEType().getInstanceClass()); if (hint == -1) { return false; } if (hint == 1) { return true; } Object value = getBaseValue(); return value != null && ValueUtils.isCollection(value); }
@Override public boolean isCollection() { EStructuralFeature pd = getPropertyDescriptor(); if (pd == null) { return false; } if( pd.isMany() ) { return true; } // if (pd instanceof IndexedPropertyDescriptor) { // return true; // } // int hint = ValueUtils.getCollectionHint(pd.getEType().getInstanceClass()); if (hint == -1) { return false; } if (hint == 1) { return true; } Object value = getBaseValue(); return value != null && ValueUtils.isCollection(value); }