@Test public void getExpectedModelType() { ViewClassDecorator deco = new ViewClassDecorator(MyView.class); Class pModelType = deco.getExpectedModelType(); assertEquals("pModelType", ListPM.class, pModelType); }
public Class<? extends PresentationModel> getExpectedModelType() { if (this.expectedModelType == null) { GenericType gt = new GenericType(viewClass); GenericType typeParam = gt.getTypeParameter(View.class.getTypeParameters()[0]); Type narrowedType = typeParam.narrow(typeParam.getType(), PresentationModel.class); if (narrowedType instanceof Class) { @SuppressWarnings("unchecked") Class<? extends PresentationModel> casted = (Class<? extends PresentationModel>) narrowedType; this.expectedModelType = casted; } else { this.expectedModelType = PresentationModel.class; } } return this.expectedModelType; }
ViewClassDecorator implements Serializable { public Class<? extends PresentationModel> getExpectedModelType() { if (this.expectedModelType == null) { GenericType gt = new GenericType(viewClass); GenericType typeParam = gt.getTypeParameter(View.class.getTypeParameters()[0]); Type narrowedType = typeParam.narrow(typeParam.getType(), PresentationModel.class); if (narrowedType instanceof Class) { @SuppressWarnings("unchecked") Class<? extends PresentationModel> casted = (Class<? extends PresentationModel>) narrowedType; this.expectedModelType = casted; } else { this.expectedModelType = PresentationModel.class; } } return this.expectedModelType; } }
ViewClassDecorator implements Serializable { public Class<? extends PresentationModel> getExpectedModelType() { if (this.expectedModelType == null) { GenericType gt = new GenericType(viewClass); GenericType typeParam = gt.getTypeParameter(View.class.getTypeParameters()[0]); Type narrowedType = typeParam.narrow(typeParam.getType(), PresentationModel.class); if (narrowedType instanceof Class) { @SuppressWarnings("unchecked") Class<? extends PresentationModel> casted = (Class<? extends PresentationModel>) narrowedType; this.expectedModelType = casted; } else { this.expectedModelType = PresentationModel.class; } } return this.expectedModelType; } ViewClassDecorator(Class<? extends View> viewClass); }
ViewClassDecorator implements Serializable { public Class<? extends PresentationModel> getExpectedModelType() { if (this.expectedModelType == null) { GenericType gt = new GenericType(viewClass); GenericType typeParam = gt.getTypeParameter(View.class.getTypeParameters()[0]); Type narrowedType = typeParam.narrow(typeParam.getType(), PresentationModel.class); if (narrowedType instanceof Class) { @SuppressWarnings("unchecked") Class<? extends PresentationModel> casted = (Class<? extends PresentationModel>) narrowedType; this.expectedModelType = casted; } else { this.expectedModelType = PresentationModel.class; } } return this.expectedModelType; } ViewClassDecorator(Class<? extends View> viewClass); Class<? extends PresentationModel> getExpectedModelType(); }
ViewClassDecorator implements Serializable { public Class<? extends PresentationModel> getExpectedModelType() { if (this.expectedModelType == null) { GenericType gt = new GenericType(viewClass); GenericType typeParam = gt.getTypeParameter(View.class.getTypeParameters()[0]); Type narrowedType = typeParam.narrow(typeParam.getType(), PresentationModel.class); if (narrowedType instanceof Class) { @SuppressWarnings("unchecked") Class<? extends PresentationModel> casted = (Class<? extends PresentationModel>) narrowedType; this.expectedModelType = casted; } else { this.expectedModelType = PresentationModel.class; } } return this.expectedModelType; } ViewClassDecorator(Class<? extends View> viewClass); Class<? extends PresentationModel> getExpectedModelType();  }