Skip to content

Commit

Permalink
#744 #638 corrections to constructors & initShim interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
elucash committed Jan 4, 2018
1 parent 7c42bef commit 5e5c6bc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
@@ -0,0 +1,17 @@
package org.immutables.fixture;

import org.immutables.value.Value;

@Value.Immutable
@Value.Style(allParameters = true)
interface AllParametersDefaultInit {
@Value.Default
default String getFoo() {
return "";
}

@Value.Default
default boolean isBar() {
return true;
}
}
@@ -0,0 +1,40 @@
/*
Copyright 2018 Immutables Authors and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.immutables.fixture.encoding;

import java.util.Date;
import org.immutables.fixture.encoding.defs.CompactDateEnabled;
import org.immutables.value.Value;

@CompactDateEnabled
public abstract class UseCompactDate {
public abstract static class Base {
@Value.Default
public Date getFirstSeen() {
return new Date();
}

@Value.Default
public Date lastSeen() {
return getFirstSeen();
}
}

@Value.Immutable
public abstract static class SomeSubclass extends Base {
public abstract String name();
}
}

This file was deleted.

Expand Up @@ -2327,12 +2327,12 @@ this.[n] = [valueFromValue v][invokeSuper v].[v.names.get]()[/valueFromValue];
[/if]
[/for]
[generateConstructorDefaultAttributes type type.constructorOmited]
[generateDerivedConstruction type type.constructorArguments]
[else][-- Alternatively a lot simpler implementation]
[for v in type.constructorArguments, n = v.name]
this.[n] = [valueFromValue v n];
[/for]
[/if]
[generateDerivedConstruction type type.constructorArguments]
[generateAfterConstruction type false]
}
[/if]
Expand Down
Expand Up @@ -220,7 +220,7 @@ private [inst.typer el.type] with_[inst.namer el]([for p in el.params][if not fo

private [inst.typer f.type] [inst.namer f] {
InitShim shim = this.[shimName];
return shim != null ? shim.[inst.directField f]() : this.[inst.directField f];
return shim != null ? shim.[if f.implField][a.names.get][else][inst.directField f][/if]() : this.[inst.directField f];
}
[/for]
[/if]
Expand Down

0 comments on commit 5e5c6bc

Please sign in to comment.