Github user sjcorbett commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/356#issuecomment-64686894
  
    I'd argue it does simplify the code. It is not only preventing `set(null)`, 
it also provides a standard way to catch missing configuration when an entity 
is created. Currently, to check a ConfigKey was set you have to write something 
like:
    
    ```
    @Override
    public void init() {
        checkNotNull(getConfig(MY_CONFIG), "Entity requires a value for 
MY_CONFIG");
    }
    ```
    
    This splits the statement of intent that a value for `MY_CONFIG` must be 
set when the entity is created away from definition of the key. There is no 
feasible way for us to generate documentation that indicates that `MY_CONFIG` 
must be set.
    
    With the change in this pull request we can replace the check in the `init` 
method by defining the config key as:
    
    ```
    ConfigKey<Object> MY_CONFIG = ConfigKeys.newConfigKey(Object.class)
            .nonNull()
            .build();
    ```
    
    Attempts to create entities missing mandatory configuration are 
automatically caught in `InternalEntityFactory`. We can extend the jsgui to 
indicate required configuration when you're adding an app or an entity (and 
even prevent submissions that are missing such values) or are browsing the 
catalogue. We can also indicate required configuration in the catalogue 
documentation on the Brooklyn website.
    
    The change is backwards compatible - all existing ConfigKeys remain 
nullable. The nulling-a-parents-key case is valid. I envisage this being used 
selectively rather than left, right and centre.
    
    It should definitely be annotated `@Beta`.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to