gRPC - Needs equivalent proto syntax Map<String, Object> - grpc

Need equivalent proto syntax for Map<String, Object>
map<string, object/Value> is failed during the generate phase

You can either use an Any or a struct to accomplish this
map<string, google.protobuf.Any>
Struct https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto#L51

Related

Post a complex object using RestTemplate in Java

I want to post a complex object (CustomResponse) using RestTemplate
class CustomResponse { String name; Map<String, Employee> employeeMap; }
How can I accomplish it?
tried using postForEntity and postForObject. it doesn't work

Declare a Map<String, Object> as a scoped variable cause problem

When I declare a Map<String, Object> scoped variable in my SpringMVC project as below:
#Bean
#SessionScope
public Map<String, Object> allProjects() {
return new TreeMap<>();
}
It is weird that it contains many unexpected things even I didn't put anything into it. Just like it is the whole session scope. It will not happen if I declare it as Map<String, String>. Is there any formal statement in document talked about this?

How to parse settings object in ShellViewModel (Caliburn.Micro)

I have a Dictionary Object defined as below
Dictionary<string, object> dictArguments = new Dictionary<string, object>();
dictArguments.Add("CommandLine", strCommandLineArguments);
And then I am passing it ShellViewModel as below.
DisplayRootViewFor<ShellViewModel>(dictArguments);
Whereas I am at a loss to figure out how and where ShellViewModel parses this argument because as far as Caliburn is concerned ShellViewModel has a single CTOR with ieventAggregator. Any pointers please?
Thanks,
Deepak
The parameter for DisplayRootViewFor accepts Windows Settings as dictionary. So for example,
Dictionary<string, object> dictArguments = new Dictionary<string, object>();
dictArguments.Add("Height", 1000);
dictArguments.Add("Width", 1500);
dictArguments.Add("ShowInTaskbar", false);
dictArguments.Add("WindowStartupLocation", WindowStartupLocation.CenterScreen);
DisplayRootViewFor<ShellViewModel>(dictArguments);
These settings would influence the Height,Width,ShowInTaskbar and WindowStartupLocation properties of your View (Caliburn Micro does that for, you do not need to do it manually).
I do not think this is useful for the storing CommandLine argument.

Spring Kafka bean return types

The documentation for spring kafka stream support shows something like:
#Bean
public KStream<Integer, String> kStream(StreamsBuilder kStreamBuilder) {
KStream<Integer, String> stream = kStreamBuilder.stream("streamingTopic1");
// ... stream config
return stream;
}
However, I might want a topology dependent on multiple streams or tables. Can I do:
#Bean
public KStream<Integer, String> kStream(StreamsBuilder kStreamBuilder) {
KStream<Integer, String> stream1 = kStreamBuilder.stream("streamingTopic1");
KStream<Integer, String> stream2 = kStreamBuilder.stream("streamingTopic1");
// ... stream config
return stream;
}
In other words, is the bean returned relevant, or is it only important that kStreamBuilder is being mutated?
It depends.
If you don't need a reference to the KStream elsewhere, there is no need to define it as a bean at all you can auto wire the StreamsBuilder which is created by the factory bean.
If you need a reference, then each one must be its own bean.
For example, Spring Cloud Stream builds a partial stream which the application then modifies. See here.

JacksonMapping Polymorphic

I am trying to parse json structure https://developers.nest.com/documentation/api-reference
Where device could be various types i want jackson to instantiate relevant objects Thermostat/SmokeAlarm,Camera etc
#Data
#ToString
public class Nest {
#JsonProperty("metadata")
private Metadata metadata;
#JsonProperty("structures")
private HashMap<String, Structure> structures;
#JsonProperty("devices")
private HashMap<String, HashMap<String, Device>> devices;
}
How would i use#JsonTypeinfo to decided which type to instatntite based on values in keys.
Another question would be how woul i get rid of all these multilevel nestings and cal have something like
#JsonProperty("devices")
private List<Device> devices;
parsed according to keys/subtypes

Resources