-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add target and multiplicity to relation enum
- Loading branch information
Showing
1 changed file
with
69 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,69 @@ | ||
package java | ||
|
||
const CLASS_TEMPLATE = `package {{ .Package }}; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
import java.util.List; | ||
import javax.validation.Valid; | ||
import javax.validation.constraints.*; | ||
import no.fint.model.{{ javaType .Stereotype }}; | ||
{{- if .Imports -}} | ||
{{ range $i := .Imports }} | ||
import {{ $i }}; | ||
{{- end -}} | ||
{{ end }} | ||
@Data | ||
@NoArgsConstructor | ||
{{ if .Extends -}} | ||
@EqualsAndHashCode(callSuper=true) | ||
@ToString(callSuper=true) | ||
{{ else -}} | ||
@EqualsAndHashCode | ||
@ToString | ||
{{ end -}} | ||
{{ if .Deprecated -}} | ||
@Deprecated | ||
{{ end -}} | ||
public {{- if .Abstract }} abstract {{- end }} class {{ .Name }} {{ if .Extends -}} extends {{ .Extends }} {{ end -}} implements {{ javaType .Stereotype }} { | ||
{{- if .Relations }} | ||
{{ $c := sub (len .Relations) 1 -}} | ||
public enum Relasjonsnavn { | ||
{{- range $i, $rel := .Relations }} | ||
{{ upperCase $rel.Name }}{{ if ne $i $c }},{{ end -}} | ||
{{ end }} | ||
} | ||
{{ end -}} | ||
{{ if .Attributes }} | ||
{{- range $att := .Attributes }} | ||
{{- if $att.Deprecated }} | ||
@Deprecated | ||
{{- end }} | ||
{{- if not $att.Optional }} | ||
{{ if $att.List }}@NotEmpty{{ else if eq "string" $att.Type }}@NotBlank{{ else }}@NotNull{{ end }} | ||
{{- end }} | ||
private {{ javaType $att.Type | validFilt $att.Type | listFilt $att.List }} {{ $att.Name }}; | ||
{{- end }} | ||
{{- end }} | ||
} | ||
` | ||
package java | ||
|
||
const CLASS_TEMPLATE = `package {{ .Package }}; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
import java.util.List; | ||
import javax.validation.Valid; | ||
import javax.validation.constraints.*; | ||
import no.fint.model.{{ javaType .Stereotype }}; | ||
{{- if .Imports -}} | ||
{{ range $i := .Imports }} | ||
import {{ $i }}; | ||
{{- end -}} | ||
{{ end }} | ||
@Data | ||
@NoArgsConstructor | ||
{{ if .Extends -}} | ||
@EqualsAndHashCode(callSuper=true) | ||
@ToString(callSuper=true) | ||
{{ else -}} | ||
@EqualsAndHashCode | ||
@ToString | ||
{{ end -}} | ||
{{ if .Deprecated -}} | ||
@Deprecated | ||
{{ end -}} | ||
public {{- if .Abstract }} abstract {{- end }} class {{ .Name }} {{ if .Extends -}} extends {{ .Extends }} {{ end -}} implements {{ javaType .Stereotype }} { | ||
{{- if .Relations }} | ||
{{ $c := sub (len .Relations) 1 -}} | ||
public enum Relasjonsnavn { | ||
{{- range $i, $rel := .Relations }} | ||
{{ upperCase $rel.Name }}("{{ $rel.Target }}", "{{ $rel.Multiplicity }}"){{ if ne $i $c }},{{ end -}} | ||
{{ end }} | ||
private final String typeName; | ||
private final String multiplicity; | ||
private Relasjonsnavn(String typeName, String multiplicity) { | ||
this.typeName = typeName; | ||
this.multiplicity = multiplicity; | ||
} | ||
public String getTypeName() { | ||
return typeName; | ||
} | ||
public String getMultiplicity() { | ||
return multiplicity; | ||
} | ||
} | ||
{{ end -}} | ||
{{ if .Attributes }} | ||
{{- range $att := .Attributes }} | ||
{{- if $att.Deprecated }} | ||
@Deprecated | ||
{{- end }} | ||
{{- if not $att.Optional }} | ||
{{ if $att.List }}@NotEmpty{{ else if eq "string" $att.Type }}@NotBlank{{ else }}@NotNull{{ end }} | ||
{{- end }} | ||
private {{ javaType $att.Type | validFilt $att.Type | listFilt $att.List }} {{ $att.Name }}; | ||
{{- end }} | ||
{{- end }} | ||
} | ||
` |