-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Description
Issue description
We have a mix of naming strategies for mutator methods, due to the original intent of extending the classfile API rather than hiding it (and thus more or less imitating its idioms).
In some cases, thing.withXxx
will modify thing
by adding or changing one of its properties. In other cases, thing.withXxx
returns a new Thing
with the added or changed property.
I propose that we adopt this mutator naming strategy:
- Methods which change something should be called
setSomething(newSomething)
(likefc.setAccess(PUBLIC)
- Methods which add something to an existing object should be called
addXxxx(xc -> { ... })
(likezc.addField(fc -> { ... })
- Methods which remove something from an existing object should be called
removeSomething(something)
(likefc.removeModifier(TRANSIENT)
) - Methods which return a new thing with the transformed property should be
Thing newThing = thing.with(newProperty);
(likeGizmo#withOutput
and probably the solution for Gizmo2: consider the default flags for classes and members #222 as well)
WDYT?
Metadata
Metadata
Assignees
Labels
2.xIssue applies to Gizmo 2.xIssue applies to Gizmo 2.x
Type
Projects
Status
Done