abstract

Is it possible to enforce constructor parameter types with `extends` or `implements` in TypeScript?

拜拜、爱过 提交于 2019-12-24 10:55:14
问题 I've looked at all the following: Abstract constructor type in TypeScript How does `type Constructor<T> = Function & { prototype: T }` apply to Abstract constructor types in TypeScript? Abstract Constructor on Abstract Class in TypeScript The third is the closest to what I'm looking for, but (unfortunately) the answer was more for the specific issue and less for the question title. This is (in a simplified sense) what I'd like to be able to do: abstract class HasStringAsOnlyConstructorArg {

Android abstract arraylist parcelable

这一生的挚爱 提交于 2019-12-24 09:14:59
问题 I have an arraylist of abstract objects(animals) and I'm trying to send and restore this array. The problem is that I need to give a creator when rebuilding the array, at this moment I'm passing a string that I check in the Animal creator and check what kind of animal I need to create. I don't thing this is the most effective, so is there a better way to create a parcelable abstract array? Here is a little demo project that describes the problem. https://github.com/Evertvandenbruel/parcelable

Can I implement an interface in a C# in an .h file?

偶尔善良 提交于 2019-12-24 07:38:24
问题 I have an interface that is used by several classes and the interface implementation is the same for all the classes. I would make it a base abstract class, but then it would stop the deriving classes from inhering from another class later on, which I need. So instead of reimplementing the same interface in all the classes, can I somehow implement the interface in one place, like an .h file and include the .h file in the cs file so the class "implements" the interface. By the way, the

Java RMI: How can I restrict RMI method to only be called internally by the client object

左心房为你撑大大i 提交于 2019-12-24 07:29:35
问题 I have an RMI model which uses a thread on each side (Client/Server Side) to maintain a client heartbeat. If the client crashes without unlocking the server, the lock will eventually timeout. I don't want the user of my client API to be able to call the methods that deal with the heartbeat/lock. However from my understanding of Java RMI, the client and server must implement a common interface which defines all the methods that I want RMI access to, and these methods must be public. Since the

Java RMI: How can I restrict RMI method to only be called internally by the client object

旧街凉风 提交于 2019-12-24 07:29:09
问题 I have an RMI model which uses a thread on each side (Client/Server Side) to maintain a client heartbeat. If the client crashes without unlocking the server, the lock will eventually timeout. I don't want the user of my client API to be able to call the methods that deal with the heartbeat/lock. However from my understanding of Java RMI, the client and server must implement a common interface which defines all the methods that I want RMI access to, and these methods must be public. Since the

Any way in Groovy/Java to identify the subclass calling a static method?

点点圈 提交于 2019-12-24 06:11:34
问题 Groovy is so powerful I wonder whether there's an easy way to do this. The scenario: I have an abstract class, AbstractSequence . Then I have two (more in reality) subclasses, called say CasedSequence and LowerCaseSequence . Each of these concrete classes has to have an "identity map", i.e. like a Set but where it is possible to extract an element based on functional equality (overriding of equals and hashCode ). So we have: class CasedSequence extends AbstractSequence { static Map

Inheritance: Proper initialization to store values into a HashMap

╄→尐↘猪︶ㄣ 提交于 2019-12-24 05:30:44
问题 I am working with separate programs, one will read in a .txt file and then that same program will store the read in values into another program containing a HashMap . The program that contains the HashMap , is named Hero.java and is an abstract class . I have a program that extends that program called Cop.java . With that in mind, I would like to know the proper way to transfer the files read in from my GameDriver.java over to the HashMap . To my knowledge, one way of doing this is

Keeping a sorted list of elements, sorted by an attribute external to that element

这一生的挚爱 提交于 2019-12-24 02:18:17
问题 I have a "manager" class maintaining a list of objects. Each Object has a certain "position", but this is not known to them, only the manager knows about this. The manager must assign each Object a position and maintain its list of Objects sorted according to this "external attribute". Note that an Object's position can change at any time. Ideally I should be able to immediately get either Element at position X or the position of Element X at any time. This is C# code. I am wondering what

How to design Java class(es) that can optionally function as Singleton?

泄露秘密 提交于 2019-12-23 22:16:00
问题 Here's the scenario: public class A { public A {} void doSomething() { // do something here... } } Right now, the class is setup where you can create multiple instances. But I also see a need where I might want to restrict the class to only one instance, i.e. Singleton class. The problem is I'm not sure how to go about the design of accomplishing both goals: Multiple instances and one instance. It doesn't sound possible to do in just one class. I imagine I'll need to use a derived class, an

Best way to store an IPv6 in UNKNOWN DB?

廉价感情. 提交于 2019-12-23 15:25:31
问题 I know that this question has been asked quite a few times, but I could not find anywhere a final resolution; so here goes: How do you store an IP (both IPv4 and IPv6) using best-practice, within a DB, without knowing the DB? This in case for DB abstraction purposes, such as PHP PDO. On a minor note, I have PHP 5.2.17, as I needed PEAR on windows. People have been suggesting to store it as a varbinary(16) and use mysql functions inet6_ntop and inet6_pton to pass IPs back and forth as strings;