Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class JacksonEnumValue {
}

static String fullyQualifiedName(Enum<?> value) {
return value.getClass().getName().replace('$', '.') + '.' + value.name();
return value.getDeclaringClass().getName().replace('$', '.') + '.' + value.name();
}

String fullyQualifiedName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.projectnessie.cel.common.types.ref.Val;
import org.projectnessie.cel.types.jackson.types.AnEnum;
import org.projectnessie.cel.types.jackson.types.CollectionsObject;
import org.projectnessie.cel.types.jackson.types.EnumWithConstantBody;
import org.projectnessie.cel.types.jackson.types.InnerType;

class Jackson2TypeDescriptionTest {
Expand Down Expand Up @@ -117,6 +118,17 @@ void basics() {
.isInstanceOf(IllegalArgumentException.class);
}

@Test
void enumConstantSpecificClassBodyUsesDeclaringClassName() {
JacksonRegistry reg = (JacksonRegistry) newRegistry();
reg.enumDescription(EnumWithConstantBody.class);

assertThat(reg.findIdent(EnumWithConstantBody.class.getName() + ".SPECIAL"))
.isEqualTo(intOf(EnumWithConstantBody.SPECIAL.ordinal()));
assertThat(reg.nativeToValue(EnumWithConstantBody.SPECIAL))
.isEqualTo(intOf(EnumWithConstantBody.SPECIAL.ordinal()));
}

@Test
void types() {
JacksonRegistry reg = (JacksonRegistry) newRegistry();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2026 The Authors of CEL-Java
*
* 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.projectnessie.cel.types.jackson.types;

public enum EnumWithConstantBody {
DEFAULT,
SPECIAL {
@Override
public String label() {
return "special";
}
};

public String label() {
return name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class JacksonEnumValue {
}

static String fullyQualifiedName(Enum<?> value) {
return value.getClass().getName().replace('$', '.') + '.' + value.name();
return value.getDeclaringClass().getName().replace('$', '.') + '.' + value.name();
}

String fullyQualifiedName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.projectnessie.cel.common.types.ref.Val;
import org.projectnessie.cel.types.jackson3.types.AnEnum;
import org.projectnessie.cel.types.jackson3.types.CollectionsObject;
import org.projectnessie.cel.types.jackson3.types.EnumWithConstantBody;
import org.projectnessie.cel.types.jackson3.types.InnerType;
import tools.jackson.databind.JavaType;

Expand Down Expand Up @@ -117,6 +118,17 @@ void basics() {
.isInstanceOf(IllegalArgumentException.class);
}

@Test
void enumConstantSpecificClassBodyUsesDeclaringClassName() {
Jackson3Registry reg = (Jackson3Registry) newRegistry();
reg.enumDescription(EnumWithConstantBody.class);

assertThat(reg.findIdent(EnumWithConstantBody.class.getName() + ".SPECIAL"))
.isEqualTo(intOf(EnumWithConstantBody.SPECIAL.ordinal()));
assertThat(reg.nativeToValue(EnumWithConstantBody.SPECIAL))
.isEqualTo(intOf(EnumWithConstantBody.SPECIAL.ordinal()));
}

@Test
void types() {
Jackson3Registry reg = (Jackson3Registry) newRegistry();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2026 The Authors of CEL-Java
*
* 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.projectnessie.cel.types.jackson3.types;

public enum EnumWithConstantBody {
DEFAULT,
SPECIAL {
@Override
public String label() {
return "special";
}
};

public String label() {
return name();
}
}
Loading