mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#768 Consistently using Type#getImportTypes() for determining imported types
This commit is contained in:
parent
18912727ca
commit
27aa40c0ec
@ -171,7 +171,7 @@ public class Decorator extends GeneratedType {
|
|||||||
@Override
|
@Override
|
||||||
public SortedSet<Type> getImportTypes() {
|
public SortedSet<Type> getImportTypes() {
|
||||||
SortedSet<Type> importTypes = super.getImportTypes();
|
SortedSet<Type> importTypes = super.getImportTypes();
|
||||||
addWithDependents( importTypes, decoratorType );
|
addIfImportRequired( importTypes, decoratorType );
|
||||||
return importTypes;
|
return importTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import java.util.SortedSet;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import javax.annotation.Generated;
|
import javax.annotation.Generated;
|
||||||
|
import javax.lang.model.type.TypeKind;
|
||||||
|
|
||||||
import org.mapstruct.ap.internal.model.common.Accessibility;
|
import org.mapstruct.ap.internal.model.common.Accessibility;
|
||||||
import org.mapstruct.ap.internal.model.common.ModelElement;
|
import org.mapstruct.ap.internal.model.common.ModelElement;
|
||||||
@ -159,24 +160,24 @@ public abstract class GeneratedType extends ModelElement {
|
|||||||
|
|
||||||
for ( MappingMethod mappingMethod : methods ) {
|
for ( MappingMethod mappingMethod : methods ) {
|
||||||
for ( Type type : mappingMethod.getImportTypes() ) {
|
for ( Type type : mappingMethod.getImportTypes() ) {
|
||||||
addWithDependents( importedTypes, type );
|
addIfImportRequired( importedTypes, type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Field field : fields ) {
|
for ( Field field : fields ) {
|
||||||
if ( field.isTypeRequiresImport() ) {
|
if ( field.isTypeRequiresImport() ) {
|
||||||
for ( Type type : field.getImportTypes() ) {
|
for ( Type type : field.getImportTypes() ) {
|
||||||
addWithDependents( importedTypes, type );
|
addIfImportRequired( importedTypes, type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Annotation annotation : annotations ) {
|
for ( Annotation annotation : annotations ) {
|
||||||
addWithDependents( importedTypes, annotation.getType() );
|
addIfImportRequired( importedTypes, annotation.getType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Type extraImport : extraImportedTypes ) {
|
for ( Type extraImport : extraImportedTypes ) {
|
||||||
addWithDependents( importedTypes, extraImport );
|
addIfImportRequired( importedTypes, extraImport );
|
||||||
}
|
}
|
||||||
|
|
||||||
return importedTypes;
|
return importedTypes;
|
||||||
@ -190,34 +191,26 @@ public abstract class GeneratedType extends ModelElement {
|
|||||||
constructor = null;
|
constructor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addWithDependents(Collection<Type> collection, Type typeToAdd) {
|
protected void addIfImportRequired(Collection<Type> collection, Type typeToAdd) {
|
||||||
if ( typeToAdd == null ) {
|
if ( typeToAdd == null ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( needsImportDeclaration( typeToAdd ) ) {
|
if ( needsImportDeclaration( typeToAdd ) ) {
|
||||||
if ( typeToAdd.isArrayType() ) {
|
|
||||||
collection.add( typeToAdd.getComponentType() );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
collection.add( typeToAdd );
|
collection.add( typeToAdd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Type type : typeToAdd.getTypeParameters() ) {
|
|
||||||
addWithDependents( collection, type );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean needsImportDeclaration(Type typeToAdd) {
|
private boolean needsImportDeclaration(Type typeToAdd) {
|
||||||
if ( !typeToAdd.isImported() ) {
|
if ( !typeToAdd.isImported() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeToAdd.getPackageName() == null ) {
|
if ( typeToAdd.getTypeMirror().getKind() != TypeKind.DECLARED ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( typeToAdd.getPackageName() != null ) {
|
||||||
if ( typeToAdd.getPackageName().startsWith( JAVA_LANG_PACKAGE ) ) {
|
if ( typeToAdd.getPackageName().startsWith( JAVA_LANG_PACKAGE ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -227,6 +220,7 @@ public abstract class GeneratedType extends ModelElement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,6 @@ public class IterableMappingMethod extends MappingMethod {
|
|||||||
types.addAll( elementAssignment.getImportTypes() );
|
types.addAll( elementAssignment.getImportTypes() );
|
||||||
}
|
}
|
||||||
if ( ( factoryMethod == null ) && ( !isExistingInstanceMapping() ) ) {
|
if ( ( factoryMethod == null ) && ( !isExistingInstanceMapping() ) ) {
|
||||||
types.addAll( getReturnType().getImportTypes() );
|
|
||||||
if ( getReturnType().getImplementationType() != null ) {
|
if ( getReturnType().getImplementationType() != null ) {
|
||||||
types.addAll( getReturnType().getImplementationType().getImportTypes() );
|
types.addAll( getReturnType().getImplementationType().getImportTypes() );
|
||||||
}
|
}
|
||||||
|
@ -151,11 +151,15 @@ public abstract class MappingMethod extends ModelElement {
|
|||||||
Set<Type> types = new HashSet<Type>();
|
Set<Type> types = new HashSet<Type>();
|
||||||
|
|
||||||
for ( Parameter param : parameters ) {
|
for ( Parameter param : parameters ) {
|
||||||
types.add( param.getType() );
|
types.addAll( param.getType().getImportTypes() );
|
||||||
|
}
|
||||||
|
|
||||||
|
types.addAll( getReturnType().getImportTypes() );
|
||||||
|
|
||||||
|
for ( Type type : thrownTypes ) {
|
||||||
|
types.addAll( type.getImportTypes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
types.add( getReturnType() );
|
|
||||||
types.addAll( thrownTypes );
|
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +76,16 @@ public class MethodReference extends MappingMethod implements Assignment {
|
|||||||
super( method );
|
super( method );
|
||||||
this.declaringMapper = declaringMapper;
|
this.declaringMapper = declaringMapper;
|
||||||
this.contextParam = null;
|
this.contextParam = null;
|
||||||
Set<Type> imported = new HashSet<Type>( method.getThrownTypes() );
|
Set<Type> imported = new HashSet<Type>();
|
||||||
if ( targetType != null ) {
|
|
||||||
imported.add( targetType );
|
for ( Type type : method.getThrownTypes() ) {
|
||||||
|
imported.addAll( type.getImportTypes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( targetType != null ) {
|
||||||
|
imported.addAll( targetType.getImportTypes() );
|
||||||
|
}
|
||||||
|
|
||||||
this.importTypes = Collections.<Type>unmodifiableSet( imported );
|
this.importTypes = Collections.<Type>unmodifiableSet( imported );
|
||||||
this.thrownTypes = method.getThrownTypes();
|
this.thrownTypes = method.getThrownTypes();
|
||||||
this.isUpdateMethod = method.getMappingTargetParameter() != null;
|
this.isUpdateMethod = method.getMappingTargetParameter() != null;
|
||||||
|
@ -265,7 +265,9 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> result = new HashSet<Type>();
|
Set<Type> result = new HashSet<Type>();
|
||||||
|
|
||||||
|
if ( getTypeMirror().getKind() == TypeKind.DECLARED ) {
|
||||||
result.add( this );
|
result.add( this );
|
||||||
|
}
|
||||||
|
|
||||||
if ( componentType != null ) {
|
if ( componentType != null ) {
|
||||||
result.addAll( componentType.getImportTypes() );
|
result.addAll( componentType.getImportTypes() );
|
||||||
@ -275,6 +277,10 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
result.addAll( parameter.getImportTypes() );
|
result.addAll( parameter.getImportTypes() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( boundingBase != null ) {
|
||||||
|
result.addAll( boundingBase.getImportTypes() );
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.astronautmapper.AstronautMapper;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.dto.AstronautDto;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.dto.SpaceshipDto;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.entity.Astronaut;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.entity.Spaceship;
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
import org.mapstruct.ap.testutil.runner.GeneratedSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for generating a mapper which references nested types (static inner classes).
|
||||||
|
*
|
||||||
|
* @author Gunnar Morling
|
||||||
|
*/
|
||||||
|
@WithClasses({
|
||||||
|
Astronaut.class, Spaceship.class, AstronautDto.class, SpaceshipDto.class, SpaceshipMapper.class,
|
||||||
|
AstronautMapper.class
|
||||||
|
})
|
||||||
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
|
public class SourceTypeContainsCollectionWithExtendsBoundTest {
|
||||||
|
|
||||||
|
private final GeneratedSource generatedSource = new GeneratedSource();
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public GeneratedSource getGeneratedSource() {
|
||||||
|
return generatedSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@IssueKey("768")
|
||||||
|
public void generatesImportsForCollectionWithExtendsBoundInSourceType() {
|
||||||
|
Astronaut astronaut = new Astronaut();
|
||||||
|
astronaut.setName( "Bob" );
|
||||||
|
|
||||||
|
Spaceship spaceship = new Spaceship();
|
||||||
|
spaceship.setAstronauts( Collections.singleton( astronaut ) );
|
||||||
|
|
||||||
|
SpaceshipDto spaceshipDto = SpaceshipMapper.INSTANCE.spaceshipToDto( spaceship );
|
||||||
|
|
||||||
|
assertThat( spaceshipDto ).isNotNull();
|
||||||
|
assertThat( spaceshipDto.getAstronauts() ).onProperty( "name" ).containsOnly( "Bob" );
|
||||||
|
|
||||||
|
generatedSource.forMapper( SpaceshipMapper.class ).containsImportFor( Astronaut.class );
|
||||||
|
generatedSource.forMapper( SpaceshipMapper.class ).containsImportFor( Spaceship.class );
|
||||||
|
generatedSource.forMapper( SpaceshipMapper.class ).containsImportFor( AstronautDto.class );
|
||||||
|
generatedSource.forMapper( SpaceshipMapper.class ).containsImportFor( SpaceshipDto.class );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.astronautmapper.AstronautMapper;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.dto.SpaceshipDto;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.entity.Spaceship;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper(uses = AstronautMapper.class)
|
||||||
|
public interface SpaceshipMapper {
|
||||||
|
|
||||||
|
SpaceshipMapper INSTANCE = Mappers.getMapper( SpaceshipMapper.class );
|
||||||
|
|
||||||
|
SpaceshipDto spaceshipToDto(Spaceship spaceship);
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound.astronautmapper;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.dto.AstronautDto;
|
||||||
|
import org.mapstruct.ap.test.imports.sourcewithextendsbound.entity.Astronaut;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AstronautMapper {
|
||||||
|
|
||||||
|
AstronautMapper INSTANCE = Mappers.getMapper( AstronautMapper.class );
|
||||||
|
|
||||||
|
AstronautDto astronautToDto(Astronaut astronaut);
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound.dto;
|
||||||
|
|
||||||
|
public class AstronautDto {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound.dto;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class SpaceshipDto {
|
||||||
|
|
||||||
|
private Collection<AstronautDto> astronauts;
|
||||||
|
|
||||||
|
public Collection<AstronautDto> getAstronauts() {
|
||||||
|
return astronauts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAstronauts(Collection<AstronautDto> astronauts) {
|
||||||
|
this.astronauts = astronauts;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound.entity;
|
||||||
|
|
||||||
|
public class Astronaut {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* 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.mapstruct.ap.test.imports.sourcewithextendsbound.entity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class Spaceship {
|
||||||
|
|
||||||
|
private Collection<? extends Astronaut> astronauts;
|
||||||
|
|
||||||
|
public Collection<? extends Astronaut> getAstronauts() {
|
||||||
|
return astronauts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAstronauts(Collection<? extends Astronaut> astronauts) {
|
||||||
|
this.astronauts = astronauts;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user