Revision 592b9851
Added by Andreas Kohlbecker about 5 years ago
src/main/java/eu/etaxonomy/vaadin/component/CompositeCustomField.java | ||
---|---|---|
12 | 12 |
import java.util.Arrays; |
13 | 13 |
import java.util.Collection; |
14 | 14 |
import java.util.List; |
15 |
import java.util.Optional; |
|
15 | 16 |
|
16 | 17 |
import com.vaadin.data.fieldgroup.FieldGroup; |
17 | 18 |
import com.vaadin.data.fieldgroup.FieldGroup.CommitEvent; |
... | ... | |
60 | 61 |
@Override |
61 | 62 |
public void preCommit(CommitEvent commitEvent) throws CommitException { |
62 | 63 |
// commit the nested bean(s) first |
63 |
if(getFieldGroup() != null){
|
|
64 |
getFieldGroup().commit(); |
|
64 |
if(getFieldGroup().isPresent()){
|
|
65 |
getFieldGroup().get().commit();
|
|
65 | 66 |
} |
66 | 67 |
} |
67 | 68 |
|
... | ... | |
181 | 182 |
* @return |
182 | 183 |
*/ |
183 | 184 |
@Override |
184 |
public abstract FieldGroup getFieldGroup();
|
|
185 |
public abstract Optional<FieldGroup> getFieldGroup();
|
|
185 | 186 |
|
186 | 187 |
/** |
187 |
* @return true if all fields having the value <code>null</code> |
|
188 |
* @return true if all fields having the value <code>null</code> and if there is no fieldgroup at all for this component.
|
|
188 | 189 |
*/ |
189 | 190 |
@SuppressWarnings("rawtypes") |
190 | 191 |
public boolean hasNullContent() { |
191 | 192 |
Collection<Field> nullValueCheckIgnore = nullValueCheckIgnoreFields(); |
192 |
return getFieldGroup().getFields().stream() |
|
193 |
if(!getFieldGroup().isPresent()){ |
|
194 |
return true; |
|
195 |
} |
|
196 |
return getFieldGroup().get().getFields().stream() |
|
193 | 197 |
.filter( |
194 | 198 |
f -> !nullValueCheckIgnore.contains(f) |
195 | 199 |
) |
Also available in: Unified diff
ref #8107 getFieldGroup() returns Optional to avoid NPEs and logging errors before rethrowing as PopupEditorException