Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
(cherry picked from commit 925fa02)
  • Loading branch information
jhoeller committed Oct 24, 2023
1 parent 1bf5d8b commit de0cb53
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 135 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1004,18 +1004,20 @@ public String toString() {
*/
protected abstract static class PropertyHandler {

@Nullable
private final Class<?> propertyType;

private final boolean readable;

private final boolean writable;

public PropertyHandler(Class<?> propertyType, boolean readable, boolean writable) {
public PropertyHandler(@Nullable Class<?> propertyType, boolean readable, boolean writable) {
this.propertyType = propertyType;
this.readable = readable;
this.writable = writable;
}

@Nullable
public Class<?> getPropertyType() {
return this.propertyType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,7 +129,6 @@ public Object getValue() throws Exception {
ReflectionUtils.makeAccessible(this.field);
return this.field.get(getWrappedInstance());
}

catch (IllegalAccessException ex) {
throw new InvalidPropertyException(getWrappedClass(),
this.field.getName(), "Field is not accessible", ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,6 +36,10 @@ protected ResolvableType getGenericApplicationEventType(String fieldName) {
}
}

protected <T> GenericTestEvent<T> createGenericTestEvent(T payload) {
return new GenericTestEvent<>(this, payload);
}


protected static class GenericTestEvent<T> extends ApplicationEvent {

Expand All @@ -51,6 +55,7 @@ public T getPayload() {
}
}


protected static class SmartGenericTestEvent<T> extends GenericTestEvent<T> implements ResolvableTypeProvider {

private final ResolvableType resolvableType;
Expand All @@ -67,52 +72,55 @@ public ResolvableType getResolvableType() {
}
}


protected static class StringEvent extends GenericTestEvent<String> {

public StringEvent(Object source, String payload) {
super(source, payload);
}
}


protected static class LongEvent extends GenericTestEvent<Long> {

public LongEvent(Object source, Long payload) {
super(source, payload);
}
}

protected <T> GenericTestEvent<T> createGenericTestEvent(T payload) {
return new GenericTestEvent<>(this, payload);
}


static class GenericEventListener implements ApplicationListener<GenericTestEvent<?>> {

@Override
public void onApplicationEvent(GenericTestEvent<?> event) {
}
}


static class ObjectEventListener implements ApplicationListener<GenericTestEvent<Object>> {

@Override
public void onApplicationEvent(GenericTestEvent<Object> event) {
}
}

static class UpperBoundEventListener
implements ApplicationListener<GenericTestEvent<? extends RuntimeException>> {

static class UpperBoundEventListener implements ApplicationListener<GenericTestEvent<? extends RuntimeException>> {

@Override
public void onApplicationEvent(GenericTestEvent<? extends RuntimeException> event) {
}
}


static class StringEventListener implements ApplicationListener<GenericTestEvent<String>> {

@Override
public void onApplicationEvent(GenericTestEvent<String> event) {
}
}


@SuppressWarnings("rawtypes")
static class RawApplicationListener implements ApplicationListener {

Expand All @@ -121,10 +129,10 @@ public void onApplicationEvent(ApplicationEvent event) {
}
}


static class TestEvents {

public GenericTestEvent<?> wildcardEvent;

}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -104,7 +104,8 @@ public void genericListenerStrictTypeNotMatchTypeErasure() {

@Test
public void genericListenerStrictTypeSubClass() {
supportsEventType(false, ObjectEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
supportsEventType(false, ObjectEventListener.class,
ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class));
}

@Test
Expand Down
Loading

0 comments on commit de0cb53

Please sign in to comment.