/** * Adds a field to the list of field members of this defined class. * * @param sName * Name of this field. * @param aInit * Initial value of this field. * @return Newly generated field */ @Nonnull public JSFieldVar field (@Nonnull @Nonempty final String sName, @Nullable final IJSExpression aInit) { final JSFieldVar aField = new JSFieldVar (this, sName, aInit); return addField (aField); }
/** * Adds a field to the list of field members of this defined class. * * @param sName * Name of this field. * @param aInit * Initial value of this field. * @return Newly generated field */ @Nonnull public JSFieldVar field (@Nonnull @Nonempty final String sName, @Nullable final IJSExpression aInit) { final JSFieldVar aField = new JSFieldVar (this, sName, aInit); return addField (aField); }
@Nonnull @Override public JSFieldVar name (@Nonnull @Nonempty final String sNewName) throws JSNameAlreadyExistsException { final String sOldName = name (); if (!sOldName.equals (sNewName)) { // make sure that the new name is available final JSFieldVar aExistingField = m_aOwnerClass.getFieldOfName (sNewName); if (aExistingField != null) throw new JSNameAlreadyExistsException (aExistingField); m_aOwnerClass.removeField (this); super.name (sNewName); m_aOwnerClass.addField (this); } return this; }
@Nonnull @Override public JSFieldVar name (@Nonnull @Nonempty final String sNewName) throws JSNameAlreadyExistsException { final String sOldName = name (); if (!sOldName.equals (sNewName)) { // make sure that the new name is available final JSFieldVar aExistingField = m_aOwnerClass.getFieldOfName (sNewName); if (aExistingField != null) throw new JSNameAlreadyExistsException (aExistingField); m_aOwnerClass.removeField (this); super.name (sNewName); m_aOwnerClass.addField (this); } return this; }