PROPOSAL: Named and Optional parameters, "Java-style"
Paul Benedict
pbenedict at apache.org
Thu Sep 1 06:53:31 PDT 2011
Sorry, I meant the named/optional parameters proposal.
2011/9/1 Frédéric Martini <frederic.martini at gmail.com>:
> This "error" is present on the new File API from Java 7...
>
>
> I'm agree that a builder can be a better choice.
> But, IMHO, the builder is not the best solution, it's only the least
> worst option...
> It's very painful and boring to write, and it's not easily extendable.
>
>
>
>
>
> Same example with a Builder :
>
>
>
> enum OpenMode { APPEND, TRUNCATE }
> enum CreateMode { CREATE, CREATE_IF_NEW, DO_NO_CREATE }
> enum SyncMode { NONE, SYNC, DSYNC }
>
> static class OpenOptions {
> private boolean followLinks = true;
> private OpenMode open = OpenMode.TRUNCATE;
> private CreateMode create = CreateMode.CREATE;
> private SyncMode syn = SyncMode.NONE;
> private boolean deleteOnClose = false;
> private boolean sparse = false;
>
> public boolean isFollowLinks() {
> return followLinks;
> }
> public OpenOptions setFollowLinks(boolean followLinks) {
> this.followLinks = followLinks;
> return this;
> }
> public OpenMode getOpen() {
> return open;
> }
> public OpenOptions setOpen(OpenMode open) {
> this.open = open;
> return this;
> }
> public CreateMode getCreate() {
> return create;
> }
> public OpenOptions setCreate(CreateMode create) {
> this.create = create;
> return this;
> }
> public SyncMode getSyn() {
> return syn;
> }
> public OpenOptions setSyn(SyncMode syn) {
> this.syn = syn;
> return this;
> }
> public boolean isDeleteOnClose() {
> return deleteOnClose;
> }
> public OpenOptions setDeleteOnClose(boolean deleteOnClose) {
> this.deleteOnClose = deleteOnClose;
> return this;
> }
> public boolean isSparse() {
> return sparse;
> }
> public OpenOptions setSparse(boolean sparse) {
> this.sparse = sparse;
> return this;
> }
> }
>
> OutputStream newOutputStream(Path path, OpenOptions options);
>
>
>
> Fred,
>
>
> 2011/9/1 向雅 <fyaoxy at gmail.com>:
>> Again, It's problem of design.
>> That example just need some kind of factory or builder to reuse.
>>
>> Don't make error for existed error!
>>
>> My words is simple, and the logic is simple as well.
>>
>> If someone not like USA(not american, not US, just only USA soo), then
>> such as tuple return value or typed vary parameter more helpfull.
>>
>> Cheers,
>> Qinxian
>>
>>
>
>
More information about the coin-dev
mailing list