wildcard

Returning Collection<? extends Type> vs Collection<Type>

旧城冷巷雨未停 提交于 2019-12-05 16:23:20
What is the difference between these two methods? Collection<Type> getTypes(); vs Collection<? extends Type> getTypes(); Does it matter if Type is a class or an interface? Especially, when designing an API, which version would be preferred and why? Collection<Type> getTypes(); Here, getTypes() must return a Collection<Type> (e.g. ArrayList<Type> or HashSet<Type> ). Collection<? extends Type> getTypes(); Here, getTypes() can return a Collection of anything that is or extends Type , (e.g. ArrayList<SubType> or HashSet<SubType> ). So anything that can be returned from the first variant can also

Using Java wildcards

徘徊边缘 提交于 2019-12-05 16:13:16
I want to implement some kind of component system in Java. There is an interface, called Form interface Form<T> { T getObject(); // ... } And I'd like to provide some abstract class called CompoundForm to assist building complex forms from simple forms. User of CompoundForm needs to provide some description of each component using Component interface interface Component<T, U> { /** Factory method to build new form for given component */ Form<U> createForm(U u, String prefix); /** Extract component of type U from the compound t */ U get(T t); /** Mutate t or build new compound of type T using

Why declare a variable as a wildcard type

梦想的初衷 提交于 2019-12-05 12:10:09
In the Java tutorials , it is sometimes written things like this : Set<?> unknownSet = new HashSet<String>(); While I understand the benefits of using type parameters and wildcards in class definitions and methods, I am wondering the following: What are the benefits of giving a variable a type that comprises a wildcard ? In real life, do people do that, and when ? Wildcards are only really useful in method parameter declarations, as they increase the range of acceptable parameter types, for example: void original(List<Number> list) { /* ... */ } void withUpperWildcard(List<? extends Number>

Is it possible to configure redirection with wildcard for Firebase hosting so that the wildcard parameter is interpolated into string?

旧时模样 提交于 2019-12-05 11:22:09
I'm looking for a way to configure a redirection in Firebase so that the "pretty" url like https://customdomainname.com/story/asdf is redirected to the real path in Firebase which is generated like https://firebasestorage.googleapis.com/v0/b/myprojectname-12345.appspot.com/o/stories%2Fasdf.m4a?alt=media&token=574e6dee-f289-468d-99ad-6e5d2ac8d6aa . For doing that I have connected a custom domain to firebase so that now I see both the default domain and the custom connected domain (probably I have been already mistaken at this step). I have installed the Firebase console, initialized a project

Generics (and Wildcards) in Java

╄→гoц情女王★ 提交于 2019-12-05 10:14:10
A book I am reading on Java tells me that the following two pieces of code are equivalent: public <T extends Animal> void takeThing(ArrayList<T> list) public void takeThing(ArrayList<? extends Animal> list); On the opposite page, I am informed that the latter piece of code uses the '?' as a wildcard, meaning that nothing can be added to the list. Does this mean that if I ever have a list (or other collection types?) that I can't make them simultaneously accept polymorphic arguments AND be re-sizable? Or have I simply misunderstood something? All help/comments appreciated, even if they go

How to use internal links with wildcard items in Sitecore?

霸气de小男生 提交于 2019-12-05 09:42:23
I have a multiple site Sitecore solution. All the sites share a product range which is stored inside a 'Shared data' node that sits at the same level as the root nodes of the sites. The individual product pages on a site use a wildcard item to lookup the product based on the last part of the URL. This means that we can't use internal links in the rich text editor to point to the product page on any of the sites because the product item does not have a specific site URL. Does anyone know of a way to overcome this, or perhaps know of a way to augment the default behavior of interal links? Wesley

Using rm * (wildcard) in envoy: No such file or directory

我们两清 提交于 2019-12-05 08:16:59
I'm using Python and Envoy. I need to delete all files in a directory. Apart from some files, the directory is empty. In a terminal this would be: rm /tmp/my_silly_directory/* Common sense dictates that in envoy, this translates into: r = envoy.run('rm /tmp/my_silly_directory/*') However: r.std_err -> "rm: cannot remove `/tmp/my_silly_directory/*': No such file or directory" Naturally there are alternatives to using envoy in this case, I am simply wondering why it doesn't work. Any clues? On UNIX, it's up to the shell to interpret wildcards like * . If you execute a program and pass an

Rails SQL query with % Wildcards works in SQLite but not PostgreSQL?

别来无恙 提交于 2019-12-05 06:06:41
I have a query I'm using for a search with :conditions like this: :conditions => ['family_name LIKE ? OR given_name LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"] The query works fine locally on SQLite, but when I push to Heroku on PostgreSQL, only the first % works for both family_name and given_name. In other words, it will match a keyword that occurs at the end of a word but not the beginning or middle. Example: There is an existing record with :family_name => "Washington" and :given_name => "George" A search for "ington" or "rge" will retrieve this record. A search for "Wash" or

Google Spreadsheet, filter doesn't allow wildcards? How to countif multiple columns with wildcards?

ε祈祈猫儿з 提交于 2019-12-05 05:59:08
When I do: B C 223 herp 223 herp 3 herp 223 derp 223 herp,derp =countif(C:C, "*herp*") I correctly get 4. When I do =count(filter(B:B, B:B=223, C:C="*herp*")) I incorrectly get 0. When I remove the "*" wildcard characters, I get 2, which is better, but doesn't get herp,derp. Does filter not support wildcard characters? If so, how can I count a row only if two of it's columns meet two different criteria which have wildcards? FILTER doesn't support wildcards, no. You need to do something like: =COUNT(FILTER(B:B,B:B=223,SEARCH("herp",C:C))) or =COUNT(FILTER(B:B,B:B=223,REGEXMATCH(C:C,"herp")))

Is there such a thing as a wildcard character in Java?

淺唱寂寞╮ 提交于 2019-12-05 04:32:36
I'm running a comparison program and at the minute it does a direct 'string-to-string' comparison and if they are an exact match it outputs that they are a match. Well, I was hoping to add an additional feature that allowed for 'similarity'... so for example: String em1 = "52494646"; String em2 = "52400646"; if (em1.equals(em2)){ output.writeUTF(dir + filenames[i]); } This is sort of a snippet of the code. I'd like it so that it skips over the "00" and still recognises it as 'almost' the same number and still outputs it. I'd imagine it would look something like String em2 = "524"+ ## +"646"