Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto properties #165

Merged
merged 4 commits into from
Dec 15, 2024
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 @@ -87,7 +87,7 @@ public void setSize(int size) {
*
* @return always returns the value of {@link ListIndex#gtype}
*/
@Property(name="item-type", constructOnly = true)
@Property(constructOnly = true)
@Override
public Type getItemType() {
return ListIndex.gtype;
Expand All @@ -98,7 +98,8 @@ public Type getItemType() {
*
* @param itemType ignored
*/
@Property(name="item-type")
@SuppressWarnings("unused")
@Property(constructOnly = true)
public void setItemType(Type itemType) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void createListModel() {
assertEquals(listIndexModel.getItemType(), ListIndexModel.ListIndex.getType());
assertEquals(1000, listIndexModel.getNItems());

var item500 = (ListIndexModel.ListIndex) listIndexModel.getItem(500);
var item500 = listIndexModel.getItem(500);
assertNotNull(item500);
assertEquals(500, item500.getIndex());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Java-GI - Java language bindings for GObject-Introspection-based libraries
* Copyright (C) 2022-2023 Jan-Willem Harmannij
* Copyright (C) 2022-2024 Jan-Willem Harmannij
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
Expand All @@ -26,11 +26,21 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The {@code @Property} annotation is used to indicate that a method (or pair
* of methods) is a property, to set a property name and flags, or to specify
* that a pair of get- and set-methods are not properties (using
* {@code skip=false}).
* <p>
* Always set the {@code @Property} annotation with the same parameters on both
* the get- and set-method.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Property {
String name() default "";
Class<? extends ParamSpec> type() default ParamSpec.class;
boolean skip() default false;
boolean readable() default true;
boolean writable() default true;
boolean construct() default false;
Expand Down
Loading