Created
May 17, 2011 15:32
-
-
Save sebersole/976704 to your computer and use it in GitHub Desktop.
metadata (building) options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Option 1 - Options part of MetadataBuilder which is more "natural" i think, but maybe not | |
// feasible if the binding code does know about MetadataBuilder (in which case see option 2). | |
public interface MetadataBuilder { | |
public static interface Options { | |
public boolean useNewIdentifierGenerators(); | |
... | |
} | |
... | |
public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled); | |
public Options getMetadataBuilderOptions(); | |
} | |
public class MetadataBuilderImpl implements MetadataBuilder { | |
... | |
private static class OptionsImpl implements Options { | |
private boolean useNewIdentifierGenerators; // I believe the default is currently false | |
... | |
public boolean useNewIdentifierGenerators() { | |
return useNewIdentifierGenerators; | |
} | |
} | |
private final OptionsImpl options = new OptionsImpl(); | |
public withNewIdentifierGeneratorsEnabled(boolean enabled) { | |
this.options.useNewIdentifierGenerators = enabled; | |
} | |
... | |
public Options getMetadataBuilderOptions() { | |
return options; | |
} | |
} | |
// Option 2 - Options part of Metadata, specifically to make it easier to pass along to binding code afaiu. | |
// A pro of this approach is that the options used to construct a Metadata are available from it after it is built. | |
public interface MetadataBuilder { | |
... | |
public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled); | |
} | |
public class MetadataBuilderImpl implements MetadataBuilder { | |
... | |
private static class OptionsImpl implements Metadata.Options { | |
private boolean useNewIdentifierGenerators; // I believe the default is currently false | |
... | |
public boolean useNewIdentifierGenerators() { | |
return useNewIdentifierGenerators; | |
} | |
} | |
private final OptionsImpl options = new OptionsImpl(); | |
public withNewIdentifierGeneratorsEnabled(boolean enabled) { | |
this.options.useNewIdentifierGenerators = enabled; | |
} | |
... | |
public Metadata buildMetadata() { | |
return new MetadataImpl( ..., options ); | |
} | |
} | |
public interface Metadata { | |
public static interface Options { | |
public boolean useNewIdentifierGenerators(); | |
... | |
} | |
public Options getMetadataOptions(); | |
} | |
You will need these options during the binding phase
There is no defined use case per-se. Just a thought that it might be useful
to query the options used to build the metadata. This is all a completely
new way to do stuff so a lot of use cases will essentially evolve as we go.
…On May 18, 2011 8:23 AM, "jpav" < ***@***.***> wrote:
I'd agree, but that's exactly why I like option 1. Seems like the builder
options should be accessed via the builder the user already has a reference
to. What use-case might drive wanting to access these options via the
Metadata interface? I'm not saying there isn't one; I just don't know what
it might be.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/976704
Yes, but that's only in the impl and only during construction time.
Yes internally that is true and the only real defined use case as of now:
the process of building the metadata will need access to these options
…On May 18, 2011 8:40 AM, "hferentschik" < ***@***.***> wrote:
You will need these options during the binding phase
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/976704
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd agree, but that's exactly why I like option 1. Seems like the builder options should be accessed via the builder the user already has a reference to. What use-case might drive wanting to access these options via the Metadata interface? I'm not saying there isn't one; I just don't know what it might be.