Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created October 3, 2011 09:35
Show Gist options
  • Select an option

  • Save ignacy/1258780 to your computer and use it in GitHub Desktop.

Select an option

Save ignacy/1258780 to your computer and use it in GitHub Desktop.
yasnippet getter/setter method for java
# -*- mode: snippet -*-
# contributor: Ignacy Moryc <imoryc@gmail.com>
# name: getAset
# key: gs
# --
private void set$1($1 ${1:$(downcase text)})) {
this.${1:$(downcase text)} = ${1:$(downcase text)};
}
private $1 get$1() {
return this.${1:$(downcase text)};
}
@enrico-benini
Copy link
Copy Markdown

enrico-benini commented Dec 30, 2025

error: Symbol’s value as variable is void: text

fixed 2026

# -*- mode: snippet -*-
# contributor: Ignacy Moryc <imoryc@gmail.com>
# name: getAset
# key: gs
# --

public void set$1($2 ${1:$(downcase yas-text)}) {
        this.${1:$(downcase yas-text)} = ${1:$(downcase yas-text)};
}

public $2 get$1() {
        return this.${1:$(downcase yas-text)};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment