/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Optional< UserDTO> user = Optional.of ( new UserDTO( null ) ) ;
user.ifPresent ( u -> {
u.getGroup ( ) .orElseThrow ( ( ) -> new EntityNotFoundException( "Grupo não encontrado" ) ) ;
} ) ;
}
public EntityNotFoundException
( String message
) { super ( message) ;
}
}
public static class UserDTO {
private GroupEntity group;
public UserDTO( GroupEntity group) {
this .group = group;
}
public Optional< GroupEntity> getGroup( ) {
return Optional.ofNullable ( this .group ) ;
}
}
public static class GroupEntity {
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCU9wdGlvbmFsPFVzZXJEVE8+IHVzZXIgPSBPcHRpb25hbC5vZihuZXcgVXNlckRUTyhudWxsKSk7CgkJdXNlci5pZlByZXNlbnQodSAtPiB7CgkJCXUuZ2V0R3JvdXAoKS5vckVsc2VUaHJvdygoKSAtPiBuZXcgRW50aXR5Tm90Rm91bmRFeGNlcHRpb24oIkdydXBvIG7Do28gZW5jb250cmFkbyIpKTsKCQl9KTsKCX0KCQoJcHVibGljIHN0YXRpYyBjbGFzcyBFbnRpdHlOb3RGb3VuZEV4Y2VwdGlvbiBleHRlbmRzIFJ1bnRpbWVFeGNlcHRpb24geyAKICAgIAlwdWJsaWMgRW50aXR5Tm90Rm91bmRF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