Skip to content

Commit

Permalink
Merge pull request #165 from jwharm/auto-properties
Browse files Browse the repository at this point in the history
Merge branch auto-properties
  • Loading branch information
jwharm authored Dec 15, 2024
2 parents 3246a26 + eecbc55 commit ab146be
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 176 deletions.
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

0 comments on commit ab146be

Please sign in to comment.