java


Android/Java - remove method reference from List


I have a array list of method references (object::method) where I insert some methods when the user clicks a button. The problem is that I also need to remove some specific method references at some point.
If I use list.remove(object::method) the method is not removed because the lambda object::method has another ID every time I use it. I want each object::method to be removable so I need a way to get the same lambda ID for each object-method-pair.
Is there a way to accomplish this or do I have to manually keep track of every ID I added so I can remove it?
From this answer http://stackoverflow.com/a/29082592/2657100
the target type of a method reference or a lambda expression should be a functional interface. Based on that only, runtime will create an instance of a class providing implementation of the given functional interface.
Try adding in a list the same method reference twice. You'll see that you'll have two different objects, and calling equals on one another will probably return false.
So you will have a hard time managing instances of functional interfaces without an auxiliary structure like an ID or a reflective Method instance, or something like that.

Related Links

How to unregisterReceiver from an activity
How to convert this segment of Java code to C++? [closed]
Thread stuck busy waiting under some circumstances and not under others
HTTP connection made in Java fails with too many redirects?
Difficulty with Collections.binarySearch
Variable within constructor is returning null?
Display labels of data [deep4j]
Extending a Pane in JavaFX
Java BufferedImage to ByteArrayOutputStream without close ByteArrayOutputStream [duplicate]
Overriding inherited CMD in Dockerfile does not always work?
C# WCF Service and Java Client
How to Start New Activity from ArrayAdapter through button?
How many jars should I add to make the application working?
SOAP - ServerSOAPFaultException is thrown instead of appropriate #WebFault exception
Can't deploy properly
How to manage bitmap memory in android?

Categories

HOME
openmp
minimum-spanning-tree
single-sign-on
iterator
onedrive
dot
electron
adb
graphql
django-imagekit
constraint-programming
uber-api
maude-system
offline
u-sql
google-cloud-ml
decomposition
samoa
google-cloud-speech
introduction
reverse-proxy
php-openssl
xpages-ssjs
spring-mybatis
strncpy
elasticsearch-ruby
xacml
dbclient
gsoap
key-value-observing
galsim
google-qpx-express-api
google-api-nodejs-client
environment-modules
html5-fullscreen
dosbox
restlet
adobe-premiere
x11-forwarding
twitch
jna
gulp-sourcemaps
texmaker
google-closure
arena-simulation
jsch
osx-mavericks
smartcontracts
network-flow
termination
revapi
atomicity
promela
hls.js
elgg
crypt
jspdf-autotable
abcpdf9
setuptools
nsfilemanager
ctest
markojs
moveit
blackberry-10
itextpdf
unity-networking
cannon.js
qdialog
iis-arr
pundit
coveralls
embedded-code
ios9.1
sonarqube5.1.2
graph-api-explorer
codeigniter-routing
markers
flask-cors
eol
braille
meteor-velocity
mysqltuner
sitemesh
blending
comaddin
interface-orientation
pygit2
pvrtc
dbproviderfactories
punbb
tomcat-valve
yetanotherforum
calling-convention
oncheckedchanged
datareader
w3wp.exe
gallio
castle-monorail
sef
photoshop-cs4
ctp4
nerddinner
putchar
scripting-languages
paul-graham

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App