ImmutableClass | An immutable class container for C | Continuous Deployment library
kandi X-RAY | ImmutableClass Summary
kandi X-RAY | ImmutableClass Summary
An immutable class container for C#, built upon System.Collections.Immutable
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ImmutableClass
ImmutableClass Key Features
ImmutableClass Examples and Code Snippets
Community Discussions
Trending Discussions on ImmutableClass
QUESTION
Here is an example of an immutable class:
...ANSWER
Answered 2020-Oct-26 at 23:02Your immutable class is like a titanium and concrete monument. Once created it is pretty much inpervious to vandalism.
Written on your monument is the location on the beach of a very pretty sand castle.
One person expects their full enjoyment of your monument to include finding that, driving over there, and gazing at the sand castle.
A second person drives over there and flattens the castle out.
The first person now feels their experience was changed.
A third person decides to hold a philosophical debate on what immutable means, and says that the monument has not changed at all: That location of the sand castle is still there, unchanged.
The first and third person decide to have a fist fight about it.
You tell me, who is right? The first, or the third?
Because it is an exact match to what's happening in your java code. You're like the first guy. Whomever said that 'make a class final, and every field final, and then the objects of that class will be immutable' is like the third.
If you want the monument's experience to not change, then either that sand castle needs to also be a titanium-and-concrete concept, which is not something the builders of this monument can do (you'd have to ask the builders of the sand castle to do this), or you need to not put the locations of non-impervious things on that monument.
In other words, either don't include fields of non-immutable types in your class if you want it to be 'experience' immutable - i.e. don't have fields of type ComplexObj
, or alternatively, make those immutable too, i.e. edit ComplexObj.java
and e.g. make that field final
.
QUESTION
Getting a really strange issue; hopefully you guys can help.
I have been using Immutables library in my android project since a long time and had no issues. The auto-generated files for Immutable objects are located in (as example) build/generated/source/apt/debug/com/package/name/ImmutableClass.java
and the project compiles and works fine.
I recently decided to use Dependency Injection in the same project and started using Dagger 2. I have used Guice in another Java project (non-Android), but never used Dagger before. All of a sudden, I am starting to get weird errors saying that the Immutables class could not be found.
Error: error: cannot find symbol class ImmutableClass
.
I tried removing the @Component
and @Module
that I created and the errors went away. The funny thing is that the file ImmutableClass.java
is still there in the same location as earlier.
Please let me know your thoughts. Thanks.
...ANSWER
Answered 2018-Sep-03 at 08:02Dagger 2 can indeed produce strange error messages when combined with other code gen libs.
If you look deeper into the errors then you'll probably find another one that says "cannot find symbol class DaggerXXXComponent" (or something similar).
You most probably have some issue that makes Dagger pre-processor to fail. Then, since Dagger fails, other code gen won't run, including Immutables.
You need to debug errors that cause Dagger failure and then Immutables errors will go away as well.
QUESTION
I am looking to do something like this (C#).
...ANSWER
Answered 2019-Aug-29 at 13:12You can basically get what you want by leveraging a std::unique_ptr
or std::shared_ptr
. If you only want one of these objects, but allow for it to be moved around, then you can use a std::unique_ptr
. If you want to allow for multiple objects ("copies") that all have the same value, then you can use a std::shared_Ptr
. Use an alias to shorten the name and provide a factory function and it becomes pretty painless. That would make your code look like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ImmutableClass
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page