AndroidPlot Configurator, Define Multiple Arguments in XML - androidplot

Is it possible to pass multiple arguments into a function through XML configuration, for example setting domainStep or rangeStep through XML?

In the case of domainStep and rangeStep, these are convenience methods that combine calls to multiple setters into one. TO set domainStep for example, you would set the two associated params domainStepMode and domainStepValue individually in your XML. This pattern should hold true for any other setter methods that take 2+ params.

Related

How to intercept only a subset of methods, and ignore the rest (groovy)?

I want to create an object used as a closure delegate, that intercept methods called with only one String as argument, and ignore the rest of the methods.
Is it possible?

Using Automapper while using specification pattern to compose objects

A specification pattern can be used to compose objects as shown in the example below:
IUser user =
UserSpecification
.ForPerson()
.WithName("myname")
.WithSurname("mysurname")
.WithPrimaryContact(ContactSpecification.ForEmailAddress("abc#email.com"))
.AndNoMoreContacts()
.Build();
This leads to manually map the data from DTO to the specification object.
Is there a way, we can use automapper to fill object while using specification pattern? Does Automapper support this in any way?
Thanks
I don't think so, typically the specification pattern is used for piecemeal setting of individual properties. The implementation of the pattern involves for each method actually setting a property, by hand.
AutoMapper always maps from an object, in the above, I don't see a source object, just a specification. If the specification filled an object, then that object was mapped to the destination, then it would work. The result above from "Build()" could be mapped to "IUser".
Otherwise, it doesn't make much sense. The code inside a specification pattern is setting up an object, and trying to map this to AutoMapper configuration I think would be far more trouble/confusing than it would be worth.

Purpose of AssertRequiredRoles?

I am implementing my own RequiredRole attribute called RequiredAnyRole, whereby I pass in a list but the user only has to be in 1 of the roles. I have implemented my own method called HasAnyRole which simply queries based on .Any() instead of .All().
I have then overridden the Execute method to use my method rather than HasAllRoles. The problem is im not sure what the method: AssertRequiredRoles is doing? It doesn't seem to be called?
Should I override that to use .Any() rather then .All() too? Here is the original code:
https://github.com/ServiceStack/ServiceStack/blob/82241fc96e187d12f9db2556aea37cf327813adc/src/ServiceStack.ServiceInterface/RequiredRoleAttribute.cs
AssertRequiredRoles is a static helper method that's can be used by other plugins like RequestLogsService to ensure access is only granted to users with the required roles. It's not called when used as a normal attribute filter.
Once you override Execute you retain full control of what gets executed, so you only need to override what you need.

Can we get declared properties of a Groovy class by its order?

I created a plain Groovy class (i.e Person class)with some properties. Now I want to get those declared attributes (which I've defined in my class) with their order, but I don't know how to do it.
I've tried to use Person.metaClass.getProperties() but it retrieves not only declared properties but also built-in Groovy ones.
Could you please help me on this: just get declared properties by its order when declaring.
Thank you so much!
I can't see a use case, but the compiler could reorder all fields declaration while creating bytecode. I'm pretty sure ordering is not a constraint on fields though it should mostly be the case for not modified/enhanced class
As per the JVM spec, generated fields should be marked SYNTHETIC (like generated methods) in the bytecode, so you can test with :
Person.getDeclaredFields().grep { !it.synthetic }
and filter the base Groovy fields like ClassInfo,metaClass and others beginning by __timestamp
But I'm not a specialist, there could be another way I don't think of
There was a question about this on the mailing list back in February of this year
The answer is, no. There is no way to get properties in the order they are declared in the class without doing some extra work.
You could parse the source file for the class, and generate an ordered list of property names from that
You could write a custom annotation, and annotate the fields with this annotation ie: #Order(1) String prop
You could make all of the classes where this matters implement an interface which forces them to have a method that returns the names of the properties in order.
Other than that, you probably want to have a re-think :-(

How can I combine/split properties with AutoMapper?

we're using Automapper (http://automapper.codeplex.com/) to map between entities and dto's. We have a situation where one property on an entity corresponds to three different properties on the dto, and we need to write some custom logic to do the mapping. Anyone know how we can do that? (We need to map both ways, from entity and from dto).
I notice that AutoMapper supports custom resolvers to do custom mapping logic, but as far as I can tell from the documentation, they only allow you to map a single property to another single property.
Thx
You can create a custom type converter. It allows you to define a converter for an entire type, not just a single property.

Resources