@Test(expected = ReadOnlyException.class) public void setValue_readOnlyNullable_shouldFail() { ColumnProperty cp = new ColumnProperty("NAME", true, true, true, false, "Ville", String.class); SQLContainer container = EasyMock.createMock(SQLContainer.class); new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); EasyMock.replay(container); cp.setValue("Kalle"); EasyMock.verify(container); }
@Override public void setValue(Object newValue) throws ReadOnlyException, ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); } if (readOnly) { throw new ReadOnlyException( "Cannot set value for read-only property."); } boolean isDateProperty = Time.class.equals(getType()) || Date.class.equals(getType()) || Timestamp.class.equals(getType()); if (newValue != null) { if (isDateProperty) { long millis = 0; if (newValue instanceof java.util.Date) { millis = ((java.util.Date) newValue).getTime(); if (Time.class.equals(getType())) { newValue = new Time(millis); } else if (Date.class.equals(getType())) { newValue = new Date(millis); } else if (Timestamp.class.equals(getType())) { newValue = new Timestamp(millis); } } } if (!getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException( "Illegal value type for ColumnProperty"); } if (isValueAlreadySet(newValue)) { return; } } changedValue = newValue; modified = true; owner.getContainer().itemChangeNotification(owner); }
ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); } if (readOnly) { throw new ReadOnlyException( "Cannot set value for read-only property."); } boolean isDateProperty = Time.class.equals(getType()) || Date.class.equals(getType()) || Timestamp.class.equals(getType()); if (newValue != null) { if (isDateProperty) { long millis = 0; if (newValue instanceof java.util.Date) { millis = ((java.util.Date) newValue).getTime(); if (Time.class.equals(getType())) { newValue = new Time(millis); } else if (Date.class.equals(getType())) { newValue = new Date(millis); } else if (Timestamp.class.equals(getType())) { newValue = new Timestamp(millis); } } } if (!getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException( "Illegal value type for ColumnProperty"); } if (isValueAlreadySet(newValue)) { return; } } changedValue = newValue; modified = true; owner.getContainer().itemChangeNotification(owner); } }
ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); } if (readOnly) { throw new ReadOnlyException( "Cannot set value for read-only property."); } boolean isDateProperty = Time.class.equals(getType()) || Date.class.equals(getType()) || Timestamp.class.equals(getType()); if (newValue != null) { if (isDateProperty) { long millis = 0; if (newValue instanceof java.util.Date) { millis = ((java.util.Date) newValue).getTime(); if (Time.class.equals(getType())) { newValue = new Time(millis); } else if (Date.class.equals(getType())) { newValue = new Date(millis); } else if (Timestamp.class.equals(getType())) { newValue = new Timestamp(millis); } } } if (!getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException( "Illegal value type for ColumnProperty"); } if (isValueAlreadySet(newValue)) { return; } } changedValue = newValue; modified = true; owner.getContainer().itemChangeNotification(owner); } @SuppressWarnings("unused") private  ColumnProperty(); @Deprecated  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, Object value,
            Class<?> type);  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, boolean primaryKey,
            Object value, Class<?> type); }
ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); } if (readOnly) { throw new ReadOnlyException( "Cannot set value for read-only property."); } boolean isDateProperty = Time.class.equals(getType()) || Date.class.equals(getType()) || Timestamp.class.equals(getType()); if (newValue != null) { if (isDateProperty) { long millis = 0; if (newValue instanceof java.util.Date) { millis = ((java.util.Date) newValue).getTime(); if (Time.class.equals(getType())) { newValue = new Time(millis); } else if (Date.class.equals(getType())) { newValue = new Date(millis); } else if (Timestamp.class.equals(getType())) { newValue = new Timestamp(millis); } } } if (!getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException( "Illegal value type for ColumnProperty"); } if (isValueAlreadySet(newValue)) { return; } } changedValue = newValue; modified = true; owner.getContainer().itemChangeNotification(owner); } @SuppressWarnings("unused") private  ColumnProperty(); @Deprecated  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, Object value,
            Class<?> type);  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, boolean primaryKey,
            Object value, Class<?> type); @Override Object getValue(); Object getOldValue(); @Override void setValue(Object newValue); @Override Class<?> getType(); @Override boolean isReadOnly(); boolean isReadOnlyChangeAllowed(); @Override void setReadOnly(boolean newStatus); boolean isPrimaryKey(); String getPropertyId(); @Deprecated @Override String toString(); void setOwner(RowItem owner); boolean isModified(); boolean isVersionColumn(); void setVersionColumn(boolean versionColumn); boolean isNullable(); boolean isPersistent(); boolean isRowIdentifier(); void commit(); }
ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); } if (readOnly) { throw new ReadOnlyException( "Cannot set value for read-only property."); } boolean isDateProperty = Time.class.equals(getType()) || Date.class.equals(getType()) || Timestamp.class.equals(getType()); if (newValue != null) { if (isDateProperty) { long millis = 0; if (newValue instanceof java.util.Date) { millis = ((java.util.Date) newValue).getTime(); if (Time.class.equals(getType())) { newValue = new Time(millis); } else if (Date.class.equals(getType())) { newValue = new Date(millis); } else if (Timestamp.class.equals(getType())) { newValue = new Timestamp(millis); } } } if (!getType().isAssignableFrom(newValue.getClass())) { throw new IllegalArgumentException( "Illegal value type for ColumnProperty"); } if (isValueAlreadySet(newValue)) { return; } } changedValue = newValue; modified = true; owner.getContainer().itemChangeNotification(owner); } @SuppressWarnings("unused") private  ColumnProperty(); @Deprecated  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, Object value,
            Class<?> type);  ColumnProperty(String propertyId, boolean readOnly,
            boolean allowReadOnlyChange, boolean nullable, boolean primaryKey,
            Object value, Class<?> type); @Override Object getValue(); Object getOldValue(); @Override void setValue(Object newValue); @Override Class<?> getType(); @Override boolean isReadOnly(); boolean isReadOnlyChangeAllowed(); @Override void setReadOnly(boolean newStatus); boolean isPrimaryKey(); String getPropertyId(); @Deprecated @Override String toString(); void setOwner(RowItem owner); boolean isModified(); boolean isVersionColumn(); void setVersionColumn(boolean versionColumn); boolean isNullable(); boolean isPersistent(); boolean isRowIdentifier(); void commit();  }