base/common/src/main/com/thesett/common/properties/ContextualProperties.java
protected Iterator getKeyIterator(final String base, final String modifier, final String key)
    {
        return new Iterator()
            {
                // The key ordering count always begins at the start of the ORDER array.
                private int i;

                public boolean hasNext()
                {
                    return (useDefaults ? ((i < ORDER.length) && (ORDER[i] > ENVIRONMENT_DEFAULTS_CUTOFF))
                                        : (i < ORDER.length));
                }

                public Object next()
                {
                    // Check that there is a next element and return null if not.
                    if (!hasNext())
                    {
                        return null;
                    }

                    // Get the next ordering count.
                    int o = ORDER[i];

                    // Do bit matching on the count to choose which elements to include in the key.
                    String result =
                        (((o & E) != 0) ? (environment + ".") : "") + (((o & B) != 0) ? (base + ".") : "") +
                        (((o & M) != 0) ? (modifier + ".") : "") + key;

                    // Increment the iterator to get the next key on the next call.
                    i++;

                    return result;
                }

                public void remove()
                {
                    // This method is not supported.
                    throw new UnsupportedOperationException("remove() is not supported on this key order iterator as " +
                        "the ordering cannot be changed");
                }
            };
    }
protected Iterator getKeyIterator(final String base, final String modifier, final String key)
    {
        return new Iterator()
            {
                // The key ordering count always begins at the start of the ORDER array.
                private int i;

                public boolean hasNext()
                {
                    return (useDefaults ? ((i < ORDER.length) && (ORDER[i] > ENVIRONMENT_DEFAULTS_CUTOFF))
                                        : (i < ORDER.length));
                }

                public Object next()
                {
                    // Check that there is a next element and return null if not.
                    if (!hasNext())
                    {
                        return null;
                    }

                    // Get the next ordering count.
                    int o = ORDER[i];

                    // Do bit matching on the count to choose which elements to include in the key.
                    String result =
                        (((o & E) != 0) ? (environment + ".") : "") + (((o & B) != 0) ? (base + ".") : "") +
                        (((o & M) != 0) ? (modifier + ".") : "") + key;

                    // Increment the iterator to get the next key on the next call.
                    i++;

                    return result;
                }

                public void remove()
                {
                    // This method is not supported.
                    throw new UnsupportedOperationException("remove() is not supported on this key order iterator as " +
                        "the ordering cannot be changed");
                }
            };
    }
For a given environment, base, modifier and key and setting of the use of default environments feature this
generates an iterator that walks over the order in which to try and access properties.

<p>See the {@link #ORDER} constant for an explanation of how the key ordering is generated.

@param  base     The name of the class to retrieve properties relative to.
@param  modifier The modifier (which may stand for a method of the class).
@param  key      The property key.

@return An Iterator over String keys defining the order in which properties should be accessed.